Skip to content

Commit da14b90

Browse files
committed
Annotate Authlib introspect_token
1 parent 32b95c1 commit da14b90

3 files changed

Lines changed: 46 additions & 3 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import Any
2+
from typing_extensions import assert_type
3+
4+
from authlib.integrations.httpx_client import AsyncOAuth2Client, OAuth2Client
5+
6+
7+
async def check_async_introspect_token(client: AsyncOAuth2Client) -> None:
8+
response = await client.introspect_token("https://example.com/introspect")
9+
assert_type(response, Any)
10+
11+
12+
def check_sync_introspect_token(client: OAuth2Client) -> None:
13+
assert_type(client.introspect_token("https://example.com/introspect"), Any)

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _typeshed import Incomplete
2-
from collections.abc import Generator
3-
from typing import NoReturn, TypeAlias
2+
from collections.abc import Awaitable, Generator
3+
from typing import Any, NoReturn, TypeAlias
44

55
from authlib.oauth2.auth import ClientAuth, TokenAuth
66
from authlib.oauth2.client import OAuth2Client as _OAuth2Client
@@ -45,6 +45,16 @@ class AsyncOAuth2Client(_OAuth2Client):
4545
async def request(self, method, url, withhold_token: bool = False, auth=..., **kwargs): ...
4646
async def stream(self, method, url, withhold_token: bool = False, auth=..., **kwargs) -> Generator[Incomplete]: ...
4747
async def ensure_active_token(self, token): ... # type: ignore[override]
48+
def introspect_token(
49+
self,
50+
url: str,
51+
token: Any | None = None,
52+
token_type_hint: str | None = None,
53+
body: Any | None = None,
54+
auth: Any = ...,
55+
headers: Any | None = None,
56+
**kwargs: Any,
57+
) -> Awaitable[_Response]: ...
4858

4959
# Inherits from httpx.Client
5060
class OAuth2Client(_OAuth2Client):
@@ -69,3 +79,13 @@ class OAuth2Client(_OAuth2Client):
6979
def handle_error(error_type: str | None, error_description: str | None) -> NoReturn: ...
7080
def request(self, method, url, withhold_token: bool = False, auth=..., **kwargs): ...
7181
def stream(self, method, url, withhold_token: bool = False, auth=..., **kwargs): ...
82+
def introspect_token(
83+
self,
84+
url: str,
85+
token: Any | None = None,
86+
token_type_hint: str | None = None,
87+
body: Any | None = None,
88+
auth: Any = ...,
89+
headers: Any | None = None,
90+
**kwargs: Any,
91+
) -> _Response: ...

stubs/Authlib/authlib/oauth2/client.pyi

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from _typeshed import Incomplete
2+
from typing import Any
23

34
from authlib.oauth2 import ClientAuth, OAuth2Error, TokenAuth
45

@@ -62,7 +63,16 @@ class OAuth2Client:
6263
def refresh_token(self, url=None, refresh_token=None, body: str = "", auth=None, headers=None, **kwargs): ...
6364
def ensure_active_token(self, token=None): ...
6465
def revoke_token(self, url, token=None, token_type_hint=None, body=None, auth=None, headers=None, **kwargs): ...
65-
def introspect_token(self, url, token=None, token_type_hint=None, body=None, auth=None, headers=None, **kwargs): ...
66+
def introspect_token(
67+
self,
68+
url: str,
69+
token: Any | None = None,
70+
token_type_hint: str | None = None,
71+
body: Any | None = None,
72+
auth: Any | None = None,
73+
headers: Any | None = None,
74+
**kwargs: Any,
75+
) -> Any: ...
6676
def register_compliance_hook(self, hook_type, hook) -> None: ...
6777
def parse_response_token(self, resp): ...
6878
def __del__(self) -> None: ...

0 commit comments

Comments
 (0)