Autogenerate Async stubs for auth0-python#13826
Open
Avasam wants to merge 9 commits intopython:mainfrom
Open
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
srittau
reviewed
Apr 15, 2025
This comment has been minimized.
This comment has been minimized.
Avasam
commented
Apr 15, 2025
This comment has been minimized.
This comment has been minimized.
5 tasks
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
srittau
reviewed
May 23, 2025
Collaborator
srittau
left a comment
There was a problem hiding this comment.
If I understand it correctly, at runtime, you can call e.g. asyncify(Flubber) on a class Flubber and this will create a (private) subclass, let's call it _AsyncFlubber(Flubber) that adds an ..._async method for each public method in class Flubber?
In this case, this approach makes sense to me, but we would need documentation describing both what I described above, but also how to correctly use the stubs.
| # Y026: Have implicit type aliases | ||
| # Y053: have literals >50 characters long | ||
| stubs/*_pb2.pyi: Y021, Y023, Y026, Y053 | ||
| stubs/auth0-python/auth0/_asyncified/**/*.pyi: Y053 |
Collaborator
There was a problem hiding this comment.
Nit: The comment above should be changed from "Generated protobuf files" to just "Generated files".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This started as an experiment/demonstration for auth0/auth0-python#615 & auth0/auth0-python#678 (comment) . But I think it's actually good enough to be considered seriously.
With these changes, the stubs are a lot closer to the actual runtime implementations.
This can surely be improved further by using actual codemods and ast-based replacements. I was just more familiar with regex to get it working this way first.
Some manual changes here (related to removing entries from
stubs/auth0-python/@tests/stubtest_allowlist.txt) can be done separately (I'll open a separate PR for them)