Skip to content

requests-oauthlib: add **kwargs to OAuth1Session.__init__#15980

Open
zhukant wants to merge 1 commit into
python:mainfrom
zhukant:requests-oauthlib-oauth1session-kwargs
Open

requests-oauthlib: add **kwargs to OAuth1Session.__init__#15980
zhukant wants to merge 1 commit into
python:mainfrom
zhukant:requests-oauthlib-oauth1session-kwargs

Conversation

@zhukant

@zhukant zhukant commented Jul 6, 2026

Copy link
Copy Markdown

At runtime, OAuth1Session.__init__ forwards **kwargs straight through to OAuth1(...):

self._client = OAuth1(
    client_key,
    ...
    force_include_body=force_include_body,
    **kwargs
)

OAuth1.__init__ already has extra keyword-only params typed in oauth1_auth.pyi (e.g. realm), and its own docstring documents this explicitly:

:param **kwargs: Additional keyword arguments passed to `OAuth1`

But the OAuth1Session stub's __init__ doesn't declare the passthrough, so legitimate calls like OAuth1Session(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 **kwargs for the same reason — this brings __init__ in line with them.

Testing

  • python tests/stubtest_third_party.py requests-oauthlib → success
  • python 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)

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).
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

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

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.

1 participant