-
Notifications
You must be signed in to change notification settings - Fork 172
Add stubs for async #678
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
Add stubs for async #678
Conversation
@kishore7snehil Could I get a review and a merge please? |
Hey @David-Gilman, I'm reviewing your PR now and will be adding comments soon. However, the merge won't be possible since |
Hey @David-Gilman, I’ve reviewed your PR. Instead of creating multiple I already have a script ready for this, and I can share the feature branch with you. You can check out the script in the scripts folder here and try running it using: poetry run python scripts/generate_stubs.py This will generate all the required Let me know if this approach works for you—if it does, we can close this PR and proceed with the scripted solution. Also, I’m not in favor of adding cc: @kpark-hrp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already have a script ready for this. You can check out the script in the scripts folder here and try running it using:
poetry run python scripts/generate_stubs.py
This will generate all the required .pyi
files for the auth0/management folder.
I’m not in favor of adding .pyi
files directly in the repo as it looks odd and can be confusing. Otherwise, we would have just added duplicate functions for async directly in each .py
file.
That requires anyone use type checkers to maintain their own fork with the .pyi files. Adding .pyi files is a common practice and would be relatively low maintenance, as well as a good middle ground between no type hints and having to maintain entire duplicate functions. You could add your script to the CI check so that any changes get updated automatically in the PR. If you feel strongly about this though and no other maintainers disagree with you, I can open a typeshed PR instead. |
@kishore7snehil Thoughts? |
@David-Gilman I would suggest to go with |
As the stubs are written here. You'd be loosing visibility on all the non-async methods and attributes. And declare the non-async versions of the classes as having Python's static typing system isn't powerful enough to generate attribute out of other attributes, or to extract type from signatures (unlike TypeSrcipt). You can't use base classes as generics either, that would make it so much easier. Here's one way you could solve this (without changing anything at runtime):
2nd option: writing a mypy plugin. But obviously that only works for mypy, and not other checkers. |
Changes
Currently type checkers such as pyre, mypy, and those included in IDEs can't handle async functions. This adds partial support by adding
.pyi
files for the management API functions ending in_async
.References
Resolves: #615
Testing
Tested with IDE and type checkers.
Checklist