From 1cc758c44b3371f8f840088901454774a3864ea8 Mon Sep 17 00:00:00 2001 From: donbarbos Date: Mon, 31 Aug 2026 11:08:57 +0400 Subject: [PATCH] [Authlib] Update to 1.8.0 Closes: #16324 --- stubs/Authlib/METADATA.toml | 2 +- .../httpx_client/assertion_client.pyi | 10 ++++++++-- .../httpx_client/oauth1_client.pyi | 13 ++++++------ .../httpx_client/oauth2_client.pyi | 20 ++++++++++--------- .../integrations/httpx_client/utils.pyi | 14 ++++++------- .../requests_client/assertion_session.pyi | 1 + .../Authlib/authlib/oauth2/rfc7521/client.pyi | 2 ++ .../authlib/oauth2/rfc7523/jwt_bearer.pyi | 2 +- .../Authlib/authlib/oauth2/rfc7523/token.pyi | 2 +- .../authlib/oauth2/rfc7523/validator.pyi | 3 ++- 10 files changed, 40 insertions(+), 29 deletions(-) diff --git a/stubs/Authlib/METADATA.toml b/stubs/Authlib/METADATA.toml index 6a322fd7f4d3..d13893e6c85d 100644 --- a/stubs/Authlib/METADATA.toml +++ b/stubs/Authlib/METADATA.toml @@ -1,3 +1,3 @@ -version = "1.7.2" +version = "1.8.0" upstream-repository = "https://github.com/authlib/authlib" dependencies = ["cryptography"] diff --git a/stubs/Authlib/authlib/integrations/httpx_client/assertion_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/assertion_client.pyi index f2061d98aedf..8ced8e61dcef 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/assertion_client.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/assertion_client.pyi @@ -1,13 +1,17 @@ from _typeshed import Incomplete +from typing import TypeAlias from authlib.oauth2.rfc7521 import AssertionClient as _AssertionClient from ..base_client import OAuthError from .oauth2_client import OAuth2Auth +USE_CLIENT_DEFAULT = Incomplete # actual httpx2.USE_CLIENT_DEFAULT +Response: TypeAlias = Incomplete # actual httpx2.Response + __all__ = ["AsyncAssertionClient"] -# Inherits from httpx.AsyncClient +# Inherits from httpx2.AsyncClient class AsyncAssertionClient(_AssertionClient): token_auth_class = OAuth2Auth oauth_error_class = OAuthError # type: ignore[assignment] @@ -24,11 +28,12 @@ class AsyncAssertionClient(_AssertionClient): claims=None, token_placement="header", scope=None, + client_id=None, **kwargs, ) -> None: ... async def request(self, method, url, withhold_token=False, auth=..., **kwargs): ... -# Inherits from httpx.Client +# Inherits from httpx2.Client class AssertionClient(_AssertionClient): token_auth_class = OAuth2Auth oauth_error_class = OAuthError # type: ignore[assignment] @@ -45,6 +50,7 @@ class AssertionClient(_AssertionClient): claims=None, token_placement="header", scope=None, + client_id=None, **kwargs, ) -> None: ... def request(self, method, url, withhold_token=False, auth=..., **kwargs): ... diff --git a/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi index 423172e9913e..6acbb15e9480 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi @@ -6,15 +6,16 @@ from typing_extensions import Never from authlib.oauth1 import ClientAuth from authlib.oauth1.client import OAuth1Client as _OAuth1Client -_Response: TypeAlias = Incomplete # actual type is httpx.Response -_Request: TypeAlias = Incomplete # actual type is httpx.Request +Auth: TypeAlias = Incomplete # actual type is httpx2.Auth +Request: TypeAlias = Incomplete # actual type is httpx2.Request +Response: TypeAlias = Incomplete # actual type is httpx2.Response -# Inherits from httpx.Auth +# Inherits from httpx2.Auth class OAuth1Auth(ClientAuth): requires_request_body: bool - def auth_flow(self, request: _Request) -> Generator[_Request, _Response]: ... + def auth_flow(self, request: Request) -> Generator[Request, Response]: ... -# Inherits from httpx.AsyncClient +# Inherits from httpx2.AsyncClient class AsyncOAuth1Client(_OAuth1Client): auth_class = OAuth1Auth def __init__( @@ -35,7 +36,7 @@ class AsyncOAuth1Client(_OAuth1Client): @staticmethod def handle_error(error_type: str | None, error_description: str | None) -> Never: ... -# Inherits from httpx.Client +# Inherits from httpx2.Client class OAuth1Client(_OAuth1Client): auth_class = OAuth1Auth def __init__( diff --git a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi index 2fc9facabeb5..705be05e479b 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi @@ -8,22 +8,24 @@ from authlib.oauth2.client import OAuth2Client as _OAuth2Client from ..base_client import OAuthError -__all__ = ["OAuth2Auth", "OAuth2ClientAuth", "AsyncOAuth2Client", "OAuth2Client"] +USE_CLIENT_DEFAULT = Incomplete # actual httpx2.USE_CLIENT_DEFAULT +Auth = Incomplete # actual type is httpx2.Auth +Request: TypeAlias = Incomplete # actual type is httpx2.Request +Response: TypeAlias = Incomplete # actual type is httpx2.Response -_Response: TypeAlias = Incomplete # actual type is httpx.Response -_Request: TypeAlias = Incomplete # actual type is httpx.Request +__all__ = ["OAuth2Auth", "OAuth2ClientAuth", "AsyncOAuth2Client", "OAuth2Client"] -# Inherits from httpx.Auth +# Inherits from httpx2.Auth class OAuth2Auth(TokenAuth): requires_request_body: bool - def auth_flow(self, request: _Request) -> Generator[_Request, _Response]: ... + def auth_flow(self, request: Request) -> Generator[Request, Response]: ... -# Inherits from httpx.Auth +# Inherits from httpx2.Auth class OAuth2ClientAuth(ClientAuth): requires_request_body: bool - def auth_flow(self, request: _Request) -> Generator[_Request, _Response]: ... + def auth_flow(self, request: Request) -> Generator[Request, Response]: ... -# Inherits from httpx.AsyncClient +# Inherits from httpx2.AsyncClient class AsyncOAuth2Client(_OAuth2Client): SESSION_REQUEST_PARAMS: list[str] client_auth_class = OAuth2ClientAuth @@ -47,7 +49,7 @@ class AsyncOAuth2Client(_OAuth2Client): async def stream(self, method, url, withhold_token: bool = False, auth=..., **kwargs) -> Generator[Incomplete]: ... async def ensure_active_token(self, token): ... # type: ignore[override] -# Inherits from httpx.Client +# Inherits from httpx2.Client class OAuth2Client(_OAuth2Client): SESSION_REQUEST_PARAMS: list[str] client_auth_class = OAuth2ClientAuth diff --git a/stubs/Authlib/authlib/integrations/httpx_client/utils.pyi b/stubs/Authlib/authlib/integrations/httpx_client/utils.pyi index 9c019d858cc4..a17dfa601a6e 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/utils.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/utils.pyi @@ -4,15 +4,13 @@ from typing import Final, TypeAlias HTTPX_CLIENT_KWARGS: Final[list[str]] -_Request: TypeAlias = Incomplete # actual type is httpx.Request -_URL: TypeAlias = Incomplete # actual type is httpx.URL -_Headers: TypeAlias = MutableMapping[str, str] # actual type is httpx.Headers -_HeaderTypes: TypeAlias = ( # actual type is httpx._types.HeaderTypes +Request: TypeAlias = Incomplete # actual type is httpx2.Request +_URL: TypeAlias = Incomplete # actual type is httpx2.URL +_Headers: TypeAlias = MutableMapping[str, str] # actual type is httpx2.Headers +_HeaderTypes: TypeAlias = ( # actual type is httpx2._types.HeaderTypes _Headers | Mapping[str, str] | Mapping[bytes, bytes] | Sequence[tuple[str, str]] | Sequence[tuple[bytes, bytes]] ) -_RequestContent: TypeAlias = str | bytes | Iterable[bytes] | AsyncIterable[bytes] # actual type is httpx._types.RequestContent +_RequestContent: TypeAlias = str | bytes | Iterable[bytes] | AsyncIterable[bytes] # actual type is httpx2._types.RequestContent def extract_client_kwargs(kwargs: dict[str, Incomplete]) -> dict[str, Incomplete]: ... -def build_request( - url: _URL | str, headers: _HeaderTypes | None, body: _RequestContent, initial_request: _Request -) -> _Request: ... +def build_request(url: _URL | str, headers: _HeaderTypes | None, body: _RequestContent, initial_request: Request) -> Request: ... diff --git a/stubs/Authlib/authlib/integrations/requests_client/assertion_session.pyi b/stubs/Authlib/authlib/integrations/requests_client/assertion_session.pyi index 87f9ae004384..941613f8cdb9 100644 --- a/stubs/Authlib/authlib/integrations/requests_client/assertion_session.pyi +++ b/stubs/Authlib/authlib/integrations/requests_client/assertion_session.pyi @@ -24,6 +24,7 @@ class AssertionSession(AssertionClient): claims=None, token_placement="header", scope=None, + client_id=None, default_timeout=None, leeway=60, **kwargs, diff --git a/stubs/Authlib/authlib/oauth2/rfc7521/client.pyi b/stubs/Authlib/authlib/oauth2/rfc7521/client.pyi index fb021f8ccb5c..c0e6f80d7f40 100644 --- a/stubs/Authlib/authlib/oauth2/rfc7521/client.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc7521/client.pyi @@ -15,6 +15,7 @@ class AssertionClient: audience: Incomplete claims: Incomplete scope: Incomplete + client_id: Incomplete token_auth: Incomplete leeway: Incomplete def __init__( @@ -28,6 +29,7 @@ class AssertionClient: claims=None, token_placement: str = "header", scope=None, + client_id=None, leeway: int = 60, **kwargs, ) -> None: ... diff --git a/stubs/Authlib/authlib/oauth2/rfc7523/jwt_bearer.pyi b/stubs/Authlib/authlib/oauth2/rfc7523/jwt_bearer.pyi index d50561b210a4..aa16b6a26f90 100644 --- a/stubs/Authlib/authlib/oauth2/rfc7523/jwt_bearer.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc7523/jwt_bearer.pyi @@ -15,7 +15,7 @@ class JWTBearerGrant(BaseGrant, TokenEndpointMixin): def sign(key, issuer, audience, subject=None, issued_at=None, expires_at=None, claims=None, **kwargs): ... def verify_claims(self, claims: dict[str, Incomplete]) -> None: ... def process_assertion_claims(self, assertion) -> dict[str, Incomplete]: ... - def extract_assertion(self, assertion: str) -> tuple[dict[str, Incomplete], Incomplete]: ... + def extract_assertion(self, assertion: str) -> tuple[dict[str, Incomplete], dict[Incomplete, Incomplete]]: ... def validate_token_request(self) -> None: ... def create_token_response(self): ... def resolve_issuer_client(self, issuer): ... diff --git a/stubs/Authlib/authlib/oauth2/rfc7523/token.pyi b/stubs/Authlib/authlib/oauth2/rfc7523/token.pyi index e8612390e482..d6c8f3800bce 100644 --- a/stubs/Authlib/authlib/oauth2/rfc7523/token.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc7523/token.pyi @@ -9,7 +9,7 @@ class JWTBearerTokenGenerator: @staticmethod def get_allowed_scope(client, scope): ... @staticmethod - def get_sub_value(user): ... + def get_sub_value(user) -> str: ... def get_token_data(self, grant_type, client, expires_in, user=None, scope=None): ... def generate(self, grant_type, client, user=None, scope=None, expires_in=None): ... def __call__(self, grant_type, client, user=None, scope=None, expires_in=None, include_refresh_token: bool = True): ... diff --git a/stubs/Authlib/authlib/oauth2/rfc7523/validator.pyi b/stubs/Authlib/authlib/oauth2/rfc7523/validator.pyi index 068756c77c80..2143fe867e38 100644 --- a/stubs/Authlib/authlib/oauth2/rfc7523/validator.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc7523/validator.pyi @@ -17,5 +17,6 @@ class JWTBearerTokenValidator(BearerTokenValidator): token_cls = JWTBearerToken public_key: Incomplete claims_options: Incomplete - def __init__(self, public_key, issuer=None, realm=None, **extra_attributes) -> None: ... + leeway: int + def __init__(self, public_key, issuer=None, realm=None, leeway: int = 60, **extra_attributes) -> None: ... def authenticate_token(self, token_string: str) -> JWTBearerToken | None: ...