Skip to content

Commit 37417c4

Browse files
committed
[Authlib] Update return types
* Remove return types for not implemented methods * Add some obvious return types * Fix some incorrect types found
1 parent 3c2dbb1 commit 37417c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+310
-233
lines changed

stubs/Authlib/authlib/common/urls.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def url_decode(query: str) -> _ExplodedQueryString: ...
1313
def add_params_to_qs(query: str, params: _ExplodedQueryString) -> str: ...
1414
def add_params_to_uri(uri: str, params: _ExplodedQueryString, fragment: bool = False): ...
1515
def quote(s: str, safe: bytes = b"/") -> str: ...
16-
def unquote(s: str) -> str: ...
16+
def unquote(s: str | bytes) -> str: ...
1717
def quote_url(s: str) -> str: ...
1818
def extract_params(raw: dict[str, str] | _ExplodedQueryString) -> _ExplodedQueryString: ...
1919
def is_valid_url(url: str, fragments_allowed: bool = True) -> bool: ...
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from _typeshed import Incomplete
12
from logging import Logger
23

34
from authlib.integrations.base_client.sync_app import OAuth1Base, OAuth2Base
@@ -8,11 +9,11 @@ __all__ = ["AsyncOAuth1Mixin", "AsyncOAuth2Mixin"]
89

910
class AsyncOAuth1Mixin(OAuth1Base):
1011
async def request(self, method, url, token=None, **kwargs): ...
11-
async def create_authorization_url(self, redirect_uri=None, **kwargs): ...
12+
async def create_authorization_url(self, redirect_uri=None, **kwargs) -> dict[Incomplete, Incomplete]: ...
1213
async def fetch_access_token(self, request_token=None, **kwargs): ...
1314

1415
class AsyncOAuth2Mixin(OAuth2Base):
15-
async def load_server_metadata(self): ...
16+
async def load_server_metadata(self) -> dict[Incomplete, Incomplete]: ...
1617
async def request(self, method, url, token=None, **kwargs): ...
17-
async def create_authorization_url(self, redirect_uri=None, **kwargs): ...
18+
async def create_authorization_url(self, redirect_uri=None, **kwargs) -> dict[Incomplete, Incomplete]: ...
1819
async def fetch_access_token(self, redirect_uri=None, **kwargs): ...
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from authlib.oidc.core.claims import UserInfo
2+
13
__all__ = ["AsyncOpenIDMixin"]
24

35
class AsyncOpenIDMixin:
46
async def fetch_jwk_set(self, force: bool = False): ...
5-
async def userinfo(self, **kwargs): ...
6-
async def parse_id_token(self, token, nonce, claims_options=None, claims_cls=None, leeway: int = 120): ...
7+
async def userinfo(self, **kwargs) -> UserInfo: ...
8+
async def parse_id_token(self, token, nonce, claims_options=None, claims_cls=None, leeway: int = 120) -> UserInfo: ...

stubs/Authlib/authlib/integrations/base_client/framework_integration.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ class FrameworkIntegration:
88
def get_state_data(self, session, state): ...
99
def set_state_data(self, session, state, data): ...
1010
def clear_state_data(self, session, state): ...
11-
def update_token(self, token, refresh_token=None, access_token=None) -> None: ...
11+
def update_token(self, token, refresh_token=None, access_token=None): ...
1212
@staticmethod
1313
def load_config(oauth, name, params): ...

stubs/Authlib/authlib/integrations/base_client/registry.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ class BaseOAuth:
1414
def __init__(self, cache=None, fetch_token=None, update_token=None) -> None: ...
1515
def create_client(self, name): ...
1616
def register(self, name, overwrite: bool = False, **kwargs): ...
17-
def generate_client_kwargs(self, name, overwrite, **kwargs): ...
17+
def generate_client_kwargs(self, name, overwrite, **kwargs) -> dict[Incomplete, Incomplete]: ...
1818
def load_config(self, name, params): ...
1919
def __getattr__(self, key): ...

stubs/Authlib/authlib/integrations/base_client/sync_app.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class OAuth1Base:
5050

5151
class OAuth1Mixin(_RequestMixin, OAuth1Base):
5252
def request(self, method, url, token=None, **kwargs): ...
53-
def create_authorization_url(self, redirect_uri=None, **kwargs): ...
53+
def create_authorization_url(self, redirect_uri=None, **kwargs) -> dict[Incomplete, Incomplete]: ...
5454
def fetch_access_token(self, request_token=None, **kwargs): ...
5555

5656
class OAuth2Base:
@@ -91,6 +91,6 @@ class OAuth2Base:
9191

9292
class OAuth2Mixin(_RequestMixin, OAuth2Base):
9393
def request(self, method, url, token=None, **kwargs): ...
94-
def load_server_metadata(self): ...
95-
def create_authorization_url(self, redirect_uri=None, **kwargs): ...
94+
def load_server_metadata(self) -> dict[Incomplete, Incomplete]: ...
95+
def create_authorization_url(self, redirect_uri=None, **kwargs) -> dict[Incomplete, Incomplete]: ...
9696
def fetch_access_token(self, redirect_uri=None, **kwargs): ...
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from authlib.oidc.core.claims import UserInfo
2+
13
class OpenIDMixin:
24
def fetch_jwk_set(self, force: bool = False): ...
3-
def userinfo(self, **kwargs): ...
4-
def parse_id_token(self, token, nonce, claims_options=None, claims_cls=None, leeway: int = 120): ...
5+
def userinfo(self, **kwargs) -> UserInfo: ...
6+
def parse_id_token(self, token, nonce, claims_options=None, claims_cls=None, leeway: int = 120) -> UserInfo | None: ...
57
def create_load_key(self): ...
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _typeshed import Incomplete
22
from collections.abc import Iterable
3-
from typing import ClassVar
3+
from typing import ClassVar, Final
44

55
from authlib.jose.rfc7516 import JWEAlgorithmWithTagAwareKeyAgreement
66

@@ -13,17 +13,19 @@ class ECDH1PUAlgorithm(JWEAlgorithmWithTagAwareKeyAgreement):
1313
aeskw: Incomplete
1414
def __init__(self, key_size=None) -> None: ...
1515
def prepare_key(self, raw_data): ...
16-
def generate_preset(self, enc_alg, key): ...
16+
def generate_preset(self, enc_alg, key) -> dict[str, Incomplete]: ...
1717
def compute_shared_key(self, shared_key_e, shared_key_s): ...
18-
def compute_fixed_info(self, headers, bit_size, tag): ...
19-
def compute_derived_key(self, shared_key, fixed_info, bit_size): ...
20-
def deliver_at_sender(self, sender_static_key, sender_ephemeral_key, recipient_pubkey, headers, bit_size, tag): ...
21-
def deliver_at_recipient(self, recipient_key, sender_static_pubkey, sender_ephemeral_pubkey, headers, bit_size, tag): ...
22-
def generate_keys_and_prepare_headers(self, enc_alg, key, sender_key, preset=None): ...
18+
def compute_fixed_info(self, headers, bit_size, tag) -> bytes: ...
19+
def compute_derived_key(self, shared_key, fixed_info, bit_size) -> bytes: ...
20+
def deliver_at_sender(self, sender_static_key, sender_ephemeral_key, recipient_pubkey, headers, bit_size, tag) -> bytes: ...
21+
def deliver_at_recipient(
22+
self, recipient_key, sender_static_pubkey, sender_ephemeral_pubkey, headers, bit_size, tag
23+
) -> bytes: ...
24+
def generate_keys_and_prepare_headers(self, enc_alg, key, sender_key, preset=None) -> dict[str, Incomplete]: ...
2325
def agree_upon_key_and_wrap_cek(self, enc_alg, headers, key, sender_key, epk, cek, tag): ...
24-
def wrap(self, enc_alg, headers, key, sender_key, preset=None): ...
25-
def unwrap(self, enc_alg, ek, headers, key, sender_key, tag=None): ...
26+
def wrap(self, enc_alg, headers, key, sender_key, preset=None) -> dict[str, Incomplete]: ...
27+
def unwrap(self, enc_alg, ek, headers, key, sender_key, tag=None) -> bytes: ...
2628

27-
JWE_DRAFT_ALG_ALGORITHMS: Incomplete
29+
JWE_DRAFT_ALG_ALGORITHMS: Final[list[ECDH1PUAlgorithm]]
2830

2931
def register_jwe_alg_draft(cls) -> None: ...

stubs/Authlib/authlib/jose/drafts/_jwe_enc_cryptography.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ class C20PEncAlgorithm(JWEEncAlgorithm):
99
key_size: Incomplete
1010
CEK_SIZE: Incomplete
1111
def __init__(self, key_size) -> None: ...
12-
def encrypt(self, msg, aad, iv, key): ...
13-
def decrypt(self, ciphertext, aad, iv, tag, key): ...
12+
def encrypt(self, msg, aad, iv, key) -> tuple[bytes, bytes]: ...
13+
def decrypt(self, ciphertext, aad, iv, tag, key) -> bytes: ...

stubs/Authlib/authlib/jose/jwk.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
from _typeshed import Incomplete
2+
from typing_extensions import deprecated
3+
4+
@deprecated("Please use `JsonWebKey` directly.")
15
def loads(obj, kid=None): ...
2-
def dumps(key, kty=None, **params): ...
6+
@deprecated("Please use `JsonWebKey` directly.")
7+
def dumps(key, kty=None, **params) -> dict[Incomplete, Incomplete]: ...

0 commit comments

Comments
 (0)