Skip to content

Improve authlib/integrations/requests_client/oauth2_session.pyi - #15865

Merged
srittau merged 10 commits into
python:mainfrom
noelleleigh:authlib/integrations/requests_client/oauth2_session.pyi
Nov 1, 2026
Merged

srittau merged 10 commits into
python:mainfrom
noelleleigh:authlib/integrations/requests_client/oauth2_session.pyi

Conversation

@noelleleigh

@noelleleigh noelleleigh commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor
  • Correct parent classes for OAuth2Auth, OAuth2ClientAuth, and OAuth2Session.
  • Remove comments that are now redundant.
  • Add type annotations to method arguments and return types.
  • Use variable annotations with ClassVar instead of assignments for class variables.

Update 2026-06-08

  • Add types-oauthlib and requests as dependencies of Authlib to pull in their types.
  • Make some types less specific on OAuth2Client to allow subclasses to override them more broadly.

- Correct parent classes for `OAuth2Auth`, `OAuth2ClientAuth`, and
  `OAuth2Session`.
- Remove comments that are now redundant.
- Add type annotations to method arguments and return types.
- Use variable annotations with `ClassVar` instead of assignments for
  class variables.
@github-actions

This comment has been minimized.

@noelleleigh

Copy link
Copy Markdown
Contributor Author

Oh, I guess the stubs from one library can't be used in another one?

stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi:6: error: Library stubs not installed for "oauthlib.oauth2"  [import-untyped]
stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi:6: note: Hint: "python3 -m pip install types-oauthlib"
stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi:6: note: (or run "mypy --install-types" to install all missing stub packages)
stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi:6: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi:7: error: Library stubs not installed for "requests"  [import-untyped]
stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi:8: error: Library stubs not installed for "requests.auth"  [import-untyped]
stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi:8: note: Hint: "python3 -m pip install types-requests"

error: Signature of "__call__" incompatible with supertype "requests.auth.AuthBase"  [override]
note:      Superclass:
note:          def __call__(self, r: PreparedRequest) -> PreparedRequest
note:      Subclass:
note:          def [_R: Request] __call__(self, req: _R) -> _R
error: Signature of "__call__" incompatible with supertype "requests.auth.AuthBase"  [override]
note:      Superclass:
note:          def __call__(self, r: PreparedRequest) -> PreparedRequest
note:      Subclass:
note:          def [_R: Request] __call__(self, req: _R) -> _R
The signature is different from Session.request
@github-actions

This comment has been minimized.

@noelleleigh

Copy link
Copy Markdown
Contributor Author

I'm not really sure what to do about all these errors outside the direct scope of this PR's changes:

pyright 1.1.410, node v24.15.0, pyright-action 3.0.2
Working directory: /home/runner/work/typeshed/typeshed
Running: /opt/hostedtoolcache/Python/3.13.13/x64/bin/pyright --pythonplatform Linux --pythonversion 3.14
Config contains unrecognized setting "$schema".
/home/runner/work/typeshed/typeshed/stubs/hvac/hvac/api/system_backend/wrapping.pyi
  /home/runner/work/typeshed/typeshed/stubs/hvac/hvac/api/system_backend/wrapping.pyi:2:29 - error: "_JSON" is unknown import symbol (reportAttributeAccessIssue)
/home/runner/work/typeshed/typeshed/stubs/python-jenkins/jenkins/__init__.pyi
  /home/runner/work/typeshed/typeshed/stubs/python-jenkins/jenkins/__init__.pyi:9:31 - error: "_Auth" is unknown import symbol (reportAttributeAccessIssue)
/home/runner/work/typeshed/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi
  /home/runner/work/typeshed/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi:123:33 - error: "_Data" is not a known attribute of module ".sessions" (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi:124:36 - error: "_HeadersUpdateMapping" is not a known attribute of module ".sessions" (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi:128:34 - error: "_Files" is not a known attribute of module ".sessions" (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi:130:35 - error: "_Params" is not a known attribute of module ".sessions" (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi:131:63 - error: "_TextMapping" is not a known attribute of module ".sessions" (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi:132:33 - error: "_Auth" is not a known attribute of module ".sessions" (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi:133:36 - error: "_Timeout" is not a known attribute of module ".sessions" (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi:135:36 - error: "_TextMapping" is not a known attribute of module ".sessions" (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi:136:34 - error: "_HooksInput" is not a known attribute of module ".sessions" (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi:138:35 - error: "_Verify" is not a known attribute of module ".sessions" (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi:139:33 - error: "_Cert" is not a known attribute of module ".sessions" (reportAttributeAccessIssue)
/home/runner/work/typeshed/typeshed/stubs/slumber/slumber/__init__.pyi
  /home/runner/work/typeshed/typeshed/stubs/slumber/slumber/__init__.pyi:5:31 - error: "_Auth" is unknown import symbol (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/slumber/slumber/__init__.pyi:5:38 - error: "_Data" is unknown import symbol (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/slumber/slumber/__init__.pyi:5:45 - error: "_Files" is unknown import symbol (reportAttributeAccessIssue)
  /home/runner/work/typeshed/typeshed/stubs/slumber/slumber/__init__.pyi:5:53 - error: "_ParamsMappingValueType" is unknown import symbol (reportAttributeAccessIssue)
/home/runner/work/typeshed/typeshed/stubs/tensorflow/tensorflow/keras/callbacks.pyi
  /home/runner/work/typeshed/typeshed/stubs/tensorflow/tensorflow/keras/callbacks.pyi:5:26 - error: "_HeadersMapping" is unknown import symbol (reportAttributeAccessIssue)
18 errors, 0 warnings, 0 informations

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@srittau srittau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It seems that the recent dependency reshuffling has fixed any CI errors.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

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

@srittau
srittau merged commit d9687da into python:main Nov 1, 2026
74 checks passed
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