Skip to content

Conversation

@robertuss12
Copy link

After recent changes to Authlib integrations, mypy complains that AsyncOAuth2Client has no attribute __aenter__ and __aexit__ when used as an async context manager.

I've looked into it and found that AsyncOAuth2Client inherits these methods from httpx.AsyncClient, but this inheritance is not reflected in the stub file. I've tried to fix it and added a test.

I had some problems with pyright tests - I couldn't get it to work without explicitly adding the __aenter__ method. I don't know why, as I haven't used pyright before. If this is a result of issues in my local environment (that's my suspicion due to other problems like unknown imports) and the explicit method is unnecessary, please let me know.

@github-actions
Copy link
Contributor

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

@donbarbos
Copy link
Contributor

Thanks you!
FTR, stub_uploader failed job is related to httpx being an optional dependency of Authlib. And this problem already has its own issue: typeshed-internal/stub_uploader#190

@robertuss12
Copy link
Author

robertuss12 commented Dec 30, 2025

I tracked down the cause of the stub_uploader error but hit a wall on fixing it. Thanks for pinning that ticket, @donbarbos — good to know it wasn't something I broke!

Question: does my PR need to wait for #190, or is there a way to bypass this check?

@donbarbos
Copy link
Contributor

donbarbos commented Dec 30, 2025

Question: does my PR need to wait for #190, or is there a way to bypass this check?

It doesn't really matter, if you want you could use Protocol to bypass this issue or just wait until the problem is resolved to use "real" httpx classes

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