Skip to content

Commit 078a97e

Browse files
authored
[Authlib] Fix AsyncOAuth2Client missing async context manager methods. (#15190)
1 parent 50fb896 commit 078a97e

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from __future__ import annotations
2+
3+
from authlib.integrations.httpx_client import AsyncOAuth2Client
4+
5+
6+
# ================================================================================
7+
# Test for AsyncOAuth2Client contex manager being correctly inherited and present.
8+
# ================================================================================
9+
async def test_client_contex_manager() -> None:
10+
async with AsyncOAuth2Client():
11+
pass

‎stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from collections.abc import Generator
2+
from contextlib import _AsyncGeneratorContextManager
23
from typing import ClassVar
3-
from typing_extensions import Never
4+
from typing_extensions import Never, Self
45

56
import httpx2
67
from authlib.oauth2.auth import ClientAuth, TokenAuth
@@ -42,8 +43,11 @@ class AsyncOAuth2Client(_OAuth2Client, httpx2.AsyncClient):
4243
leeway=60,
4344
**kwargs,
4445
) -> None: ...
46+
async def __aenter__(self) -> Self: ...
4547
async def request(self, method, url, withhold_token: bool = False, auth=..., **kwargs): ...
46-
async def stream(self, method, url, withhold_token: bool = False, auth=..., **kwargs) -> Generator[Response]: ... # type: ignore[override]
48+
def stream(
49+
self, method, url, withhold_token: bool = False, auth=..., **kwargs
50+
) -> _AsyncGeneratorContextManager[Response]: ...
4751
async def ensure_active_token(self, token): ... # type: ignore[override]
4852

4953
class OAuth2Client(_OAuth2Client, httpx2.Client):

0 commit comments

Comments
 (0)