requests-oauthlib: add **kwargs to OAuth1Session.__init__#15980
Open
zhukant wants to merge 1 commit into
Open
Conversation
At runtime OAuth1Session.__init__ forwards **kwargs straight through to OAuth1(...) (see requests_oauthlib/oauth1_session.py), which already has extra keyword-only params typed in oauth1_auth.pyi (e.g. realm). The OAuth1Session stub was missing the passthrough, so legitimate calls like OAuth1Session(client_key=..., realm=...) failed with a spurious "No parameter named realm" error. Sibling methods on the same class (authorization_url, fetch_request_token, fetch_access_token) already use a bare **kwargs for the same reason. Verified with tests/stubtest_third_party.py, tests/mypy_test.py (all supported Python versions), and pre-commit (ruff/black/flake8-pyi).
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
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.
At runtime,
OAuth1Session.__init__forwards**kwargsstraight through toOAuth1(...):OAuth1.__init__already has extra keyword-only params typed inoauth1_auth.pyi(e.g.realm), and its own docstring documents this explicitly:But the
OAuth1Sessionstub's__init__doesn't declare the passthrough, so legitimate calls likeOAuth1Session(client_key=..., realm=...)fail type-checking with a spurious "No parameter named realm" error. Sibling methods on the same class (authorization_url,fetch_request_token,fetch_access_token) already use a bare**kwargsfor the same reason — this brings__init__in line with them.Testing
python tests/stubtest_third_party.py requests-oauthlib→ successpython tests/mypy_test.py stubs/requests-oauthlib→ success on all supported Python versions (3.10–3.15)pre-commit run --files stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi→ all hooks passed (ruff, black, flake8-pyi)