diff --git a/stubs/Authlib/@tests/test_cases/check_integration_httpx_client_oauth2.py b/stubs/Authlib/@tests/test_cases/check_integration_httpx_client_oauth2.py new file mode 100644 index 000000000000..1ba02ecdb151 --- /dev/null +++ b/stubs/Authlib/@tests/test_cases/check_integration_httpx_client_oauth2.py @@ -0,0 +1,11 @@ +from __future__ import annotations + +from authlib.integrations.httpx_client import AsyncOAuth2Client + + +# ================================================================================ +# Test for AsyncOAuth2Client contex manager being correctly inherited and present. +# ================================================================================ +async def test_client_contex_manager() -> None: + async with AsyncOAuth2Client(): + pass diff --git a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi index 62e935c90f99..63f239f0fd49 100644 --- a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi +++ b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi @@ -1,6 +1,7 @@ from collections.abc import Generator +from contextlib import _AsyncGeneratorContextManager from typing import ClassVar -from typing_extensions import Never +from typing_extensions import Never, Self import httpx2 from authlib.oauth2.auth import ClientAuth, TokenAuth @@ -42,8 +43,11 @@ class AsyncOAuth2Client(_OAuth2Client, httpx2.AsyncClient): leeway=60, **kwargs, ) -> None: ... + async def __aenter__(self) -> Self: ... 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[Response]: ... # type: ignore[override] + def stream( + self, method, url, withhold_token: bool = False, auth=..., **kwargs + ) -> _AsyncGeneratorContextManager[Response]: ... async def ensure_active_token(self, token): ... # type: ignore[override] class OAuth2Client(_OAuth2Client, httpx2.Client):