Skip to content

Add stubs for _async methods #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
5 tasks done
dgilman-hrp opened this issue Apr 9, 2024 · 7 comments
Open
5 tasks done

Add stubs for _async methods #615

dgilman-hrp opened this issue Apr 9, 2024 · 7 comments
Labels
feature request A feature has been asked for or suggested by the community

Comments

@dgilman-hrp
Copy link

Checklist

  • I have looked into the Readme and Examples, and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Describe the problem you'd like to have solved

The built-in asyncify is very useful, but the way it's implemented means that typing checking (such as via Pyre) and IDEs have no idea these exist.

Describe the ideal solution

Add function stubs for every method that supports async with type hinting.

Alternatives and current workarounds

No response

Additional context

No response

@dgilman-hrp dgilman-hrp added the feature request A feature has been asked for or suggested by the community label Apr 9, 2024
@David-Gilman David-Gilman mentioned this issue Feb 28, 2025
3 tasks
@Avasam
Copy link

Avasam commented Apr 14, 2025

#678 (comment)

Here's one way you could solve this (without changing anything at runtime): Generate stubs for all classes you expect to "Asyncify" as was talked here. But with the following differences:

  • Generate it in a subfolder that doesn't exist at runtime (ie: auth0._asyncified.*)
  • Rename all the generated classes to help differentiate them (something like class UsersWrapped(Users): for base class Users)
  • Decorate all generated classes with @typing.type_check_only
  • Generate a massive overload for auth0.asyncify.asyncify that maps original classes to stub-only asyncified/wrapped classes.
  • Optional: Generate said stubs on install/editable install/wheel creation. That way they don't pollute the source and history.

Like this: Avasam/typeshed#43 (files)

@kishore7snehil
Copy link
Contributor

I believe this issue can be closed now as we already have a workaround discussed on this thread.

@Dreamsorcerer
Copy link

Isn't that workaround to wait for Avasam to merge the typeshed PR and then use types-auth0-python instead? Still looks to me like something needs to be done in this repo in order to provide types directly and close #612.

@kishore7snehil
Copy link
Contributor

@Dreamsorcerer There was a PR for the same where it was asked to add the .py files in the repo itself. I suggested to use the script to generate the async files.

That's the same approach @Avasam (correct me if I am wrong ) is pushing forward but with some specific tweaks to the generation logic.

If he is willing to add a PR to this repo, I can review it and take it forward.

@Dreamsorcerer
Copy link

If he is willing to add a PR to this repo, I can review it and take it forward.

Of course. My point was just that this issue isn't closed until that PR gets created and merged.

@Avasam
Copy link

Avasam commented May 3, 2025

If you don't mind having a script to run once in a while to "keep the stubs in sync". I can migrate the script I made for python/typeshed#13826 to over here.
Can probably include some CI check to ensure that running it wouldn't produce any change (ie: not forgotten by the contributor).
I see you have a https://github.com/auth0/auth0-python/blob/master/.pre-commit-config.yaml , it could also be added there.

Then I think you'll have everything you need to declare this library as "first-party typed".

@kishore7snehil
Copy link
Contributor

@Avasam Please feel free to open a PR. I can review it and will update you acordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A feature has been asked for or suggested by the community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants