Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

David-Gilman
Copy link

@David-Gilman David-Gilman commented Feb 28, 2025

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

@David-Gilman David-Gilman requested a review from a team as a code owner February 28, 2025 17:21
@David-Gilman
Copy link
Author

@kishore7snehil Could I get a review and a merge please?

@kishore7snehil
Copy link
Contributor

Hey @David-Gilman, I'm reviewing your PR now and will be adding comments soon. However, the merge won't be possible since Snyk is failing here. I'll take your changes and create a new PR to address this. I'll make sure to give you proper credits both in the PR and in the release. Thanks for your contribution!

@kishore7snehil
Copy link
Contributor

kishore7snehil commented Mar 19, 2025

Hey @David-Gilman, I’ve reviewed your PR. Instead of creating multiple .pyi files for async stubs manually, I’d recommend using a script to handle this, as having too many .pyi files might be confusing for developers.

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 .pyi files for the auth0/management folder.

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 .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.

cc: @kpark-hrp

Copy link
Contributor

@kishore7snehil kishore7snehil left a 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.

@David-Gilman
Copy link
Author

David-Gilman commented Mar 19, 2025

@kishore7snehil

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.

@David-Gilman
Copy link
Author

@kishore7snehil Thoughts?

@kishore7snehil
Copy link
Contributor

@David-Gilman I would suggest to go with typeshed PR.Meanwhile I will look out for adding the script in CI. But I can't give any immediate timeline right now as the team is working on high priority tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add stubs for _async methods
3 participants