Skip to content

Autogenerate Async stubs for auth0-python #13826

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
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Apr 14, 2025

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)

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@@ -11,5 +11,6 @@ per-file-ignores =
# 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The comment above should be changed from "Generated protobuf files" to just "Generated files".

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.

2 participants