Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion stubs/Authlib/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ authlib.integrations.django_oauth2.*
authlib.integrations.flask_client.*
authlib.integrations.flask_oauth1.*
authlib.integrations.flask_oauth2.*
authlib.integrations.httpx_client.*
authlib.integrations.requests_client.*
authlib.integrations.sqla_oauth2.*
authlib.integrations.starlette_client.*
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion stubs/Authlib/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
version = "1.6.6"
upstream_repository = "https://github.com/lepture/authlib"
requires = ["cryptography"]
requires = ["cryptography", "httpx"]

[tool.stubtest]
extras = ["httpx"]
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from _typeshed import Incomplete
from collections.abc import Generator
from contextlib import _AsyncGeneratorContextManager
from typing import NoReturn
from typing_extensions import TypeAlias
from typing_extensions import Self, TypeAlias

import httpx
from authlib.oauth2.auth import ClientAuth, TokenAuth
from authlib.oauth2.client import OAuth2Client as _OAuth2Client

Expand All @@ -24,7 +26,7 @@ class OAuth2ClientAuth(ClientAuth):
def auth_flow(self, request: _Request) -> Generator[_Request, _Response, None]: ...

# Inherits from httpx.AsyncClient
class AsyncOAuth2Client(_OAuth2Client):
class AsyncOAuth2Client(_OAuth2Client, httpx.AsyncClient):
SESSION_REQUEST_PARAMS: list[str]
client_auth_class = OAuth2ClientAuth
token_auth_class = OAuth2Auth
Expand All @@ -43,8 +45,11 @@ class AsyncOAuth2Client(_OAuth2Client):
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[Incomplete]: ...
def stream(
self, method, url, withhold_token: bool = False, auth=..., **kwargs
) -> _AsyncGeneratorContextManager[httpx.Response]: ...
async def ensure_active_token(self, token): ... # type: ignore[override]

# Inherits from httpx.Client
Expand Down
Loading