diff --git a/stubs/Authlib/@tests/stubtest_allowlist.txt b/stubs/Authlib/@tests/stubtest_allowlist.txt index 0bffd44ab229..d84c31291389 100644 --- a/stubs/Authlib/@tests/stubtest_allowlist.txt +++ b/stubs/Authlib/@tests/stubtest_allowlist.txt @@ -48,6 +48,5 @@ authlib.integrations.django_oauth2.* authlib.integrations.flask_client.* authlib.integrations.flask_oauth1.* authlib.integrations.flask_oauth2.* -authlib.integrations.httpx_client.* authlib.integrations.sqla_oauth2.* authlib.integrations.starlette_client.* diff --git a/stubs/Authlib/METADATA.toml b/stubs/Authlib/METADATA.toml index e99ec93ad555..fac7a8d163d5 100644 --- a/stubs/Authlib/METADATA.toml +++ b/stubs/Authlib/METADATA.toml @@ -1,4 +1,4 @@ -version = "1.7.2" +version = "1.8.0" upstream-repository = "https://github.com/authlib/authlib" dependencies = ["cryptography"] -optional-dependencies = ["requests"] +optional-dependencies = ["requests", "httpx2"] diff --git a/stubs/Authlib/authlib/integrations/httpx_client/assertion_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/assertion_client.pyi index f2061d98aedf..fe8b01939cd4 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/assertion_client.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/assertion_client.pyi @@ -1,14 +1,17 @@ from _typeshed import Incomplete +import httpx2 from authlib.oauth2.rfc7521 import AssertionClient as _AssertionClient from ..base_client import OAuthError from .oauth2_client import OAuth2Auth +USE_CLIENT_DEFAULT = httpx2.USE_CLIENT_DEFAULT +Response = httpx2.Response + __all__ = ["AsyncAssertionClient"] -# Inherits from httpx.AsyncClient -class AsyncAssertionClient(_AssertionClient): +class AsyncAssertionClient(_AssertionClient, httpx2.AsyncClient): token_auth_class = OAuth2Auth oauth_error_class = OAuthError # type: ignore[assignment] JWT_BEARER_GRANT_TYPE: Incomplete @@ -24,12 +27,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 -class AssertionClient(_AssertionClient): +class AssertionClient(_AssertionClient, httpx2.Client): token_auth_class = OAuth2Auth oauth_error_class = OAuthError # type: ignore[assignment] JWT_BEARER_GRANT_TYPE: Incomplete @@ -45,6 +48,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..19c65b3cd70f 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi @@ -1,21 +1,19 @@ -from _typeshed import Incomplete from collections.abc import Generator -from typing import TypeAlias from typing_extensions import Never +import httpx2 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 = httpx2.Auth +Request = httpx2.Request +Response = httpx2.Response -# Inherits from httpx.Auth -class OAuth1Auth(ClientAuth): +class OAuth1Auth(Auth, 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 -class AsyncOAuth1Client(_OAuth1Client): +class AsyncOAuth1Client(_OAuth1Client, httpx2.AsyncClient): # type: ignore[misc] # incompatible definitions of "auth" in the base classes auth_class = OAuth1Auth def __init__( self, @@ -35,8 +33,7 @@ class AsyncOAuth1Client(_OAuth1Client): @staticmethod def handle_error(error_type: str | None, error_description: str | None) -> Never: ... -# Inherits from httpx.Client -class OAuth1Client(_OAuth1Client): +class OAuth1Client(_OAuth1Client, httpx2.Client): # type: ignore[misc] # incompatible definitions of "auth" in the base classes auth_class = OAuth1Auth def __init__( self, diff --git a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi index 2fc9facabeb5..cba2ec0f2880 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi @@ -1,30 +1,28 @@ -from _typeshed import Incomplete from collections.abc import Generator -from typing import TypeAlias from typing_extensions import Never +import httpx2 from authlib.oauth2.auth import ClientAuth, TokenAuth from authlib.oauth2.client import OAuth2Client as _OAuth2Client from ..base_client import OAuthError -__all__ = ["OAuth2Auth", "OAuth2ClientAuth", "AsyncOAuth2Client", "OAuth2Client"] +USE_CLIENT_DEFAULT = httpx2.USE_CLIENT_DEFAULT +Auth = httpx2.Auth +Request = httpx2.Request +Response = 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 -class OAuth2Auth(TokenAuth): +class OAuth2Auth(Auth, 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 -class OAuth2ClientAuth(ClientAuth): +class OAuth2ClientAuth(Auth, 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 -class AsyncOAuth2Client(_OAuth2Client): +class AsyncOAuth2Client(_OAuth2Client, httpx2.AsyncClient): SESSION_REQUEST_PARAMS: list[str] client_auth_class = OAuth2ClientAuth token_auth_class = OAuth2Auth @@ -44,11 +42,10 @@ class AsyncOAuth2Client(_OAuth2Client): **kwargs, ) -> None: ... async def request(self, method, url, withhold_token: bool = False, auth=..., **kwargs): ... - async def stream(self, method, url, withhold_token: bool = False, auth=..., **kwargs) -> Generator[Incomplete]: ... + async def stream(self, method, url, withhold_token: bool = False, auth=..., **kwargs) -> Generator[Response]: ... # type: ignore[override] async def ensure_active_token(self, token): ... # type: ignore[override] -# Inherits from httpx.Client -class OAuth2Client(_OAuth2Client): +class OAuth2Client(_OAuth2Client, httpx2.Client): SESSION_REQUEST_PARAMS: list[str] client_auth_class = OAuth2ClientAuth token_auth_class = OAuth2Auth diff --git a/stubs/Authlib/authlib/integrations/httpx_client/utils.pyi b/stubs/Authlib/authlib/integrations/httpx_client/utils.pyi index 9c019d858cc4..14b18cf83602 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/utils.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/utils.pyi @@ -1,18 +1,14 @@ from _typeshed import Incomplete -from collections.abc import AsyncIterable, Iterable, Mapping, MutableMapping, Sequence -from typing import Final, TypeAlias +from typing import Final + +import httpx2 +from httpx2._types import HeaderTypes, RequestContent 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 - _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 +Request = httpx2.Request 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: ... + url: httpx2.URL | str, headers: HeaderTypes | None, body: RequestContent, initial_request: httpx2.Request +) -> httpx2.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: ...