Skip to content

Commit 3370aa6

Browse files
authored
[Authlib] Add missing stubs (#14368)
1 parent 4c3560d commit 3370aa6

29 files changed

+158
-94
lines changed

stubs/Authlib/@tests/stubtest_allowlist.txt

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,5 @@
11
# TODO: check these entries
2-
authlib.jose.ECKey.PRIVATE_KEY_CLS
3-
authlib.jose.ECKey.PUBLIC_KEY_CLS
4-
authlib.jose.RSAKey.PRIVATE_KEY_CLS
5-
authlib.jose.RSAKey.PUBLIC_KEY_CLS
6-
authlib.jose.drafts._jwe_algorithms.ECDH1PUAlgorithm.description
7-
authlib.jose.drafts._jwe_algorithms.ECDH1PUAlgorithm.name
82
authlib.jose.drafts._jwe_enc_cryptodome
9-
authlib.jose.drafts._jwe_enc_cryptography.C20PEncAlgorithm.description
10-
authlib.jose.drafts._jwe_enc_cryptography.C20PEncAlgorithm.name
11-
authlib.jose.rfc7518.ECDHESAlgorithm.description
12-
authlib.jose.rfc7518.ECDHESAlgorithm.name
13-
authlib.jose.rfc7518.ECKey.PRIVATE_KEY_CLS
14-
authlib.jose.rfc7518.ECKey.PUBLIC_KEY_CLS
15-
authlib.jose.rfc7518.RSAKey.PRIVATE_KEY_CLS
16-
authlib.jose.rfc7518.RSAKey.PUBLIC_KEY_CLS
17-
authlib.jose.rfc7518.ec_key.ECKey.PRIVATE_KEY_CLS
18-
authlib.jose.rfc7518.ec_key.ECKey.PUBLIC_KEY_CLS
19-
authlib.jose.rfc7518.jwe_algs.ECDHESAlgorithm.description
20-
authlib.jose.rfc7518.jwe_algs.ECDHESAlgorithm.name
21-
authlib.jose.rfc7518.rsa_key.RSAKey.PRIVATE_KEY_CLS
22-
authlib.jose.rfc7518.rsa_key.RSAKey.PUBLIC_KEY_CLS
233
authlib.oauth2.OAuth2Client.client_auth_class
244
authlib.oauth2.OAuth2Client.oauth_error_class
255
authlib.oauth2.OAuth2Client.token_auth_class
@@ -30,7 +10,24 @@ authlib.oauth2.rfc7521.AssertionClient.oauth_error_class
3010
authlib.oauth2.rfc7521.client.AssertionClient.oauth_error_class
3111
authlib.oauth2.rfc7523.JWTBearerTokenValidator.token_cls
3212
authlib.oauth2.rfc7523.validator.JWTBearerTokenValidator.token_cls
33-
authlib.oauth2.rfc9068.claims.JWTAccessTokenClaims.validate
13+
14+
# Are set to `None` by default, initialized later:
15+
authlib.jose.drafts._jwe_algorithms.ECDH1PUAlgorithm.description
16+
authlib.jose.drafts._jwe_algorithms.ECDH1PUAlgorithm.name
17+
authlib.jose.drafts._jwe_enc_cryptography.C20PEncAlgorithm.description
18+
authlib.jose.drafts._jwe_enc_cryptography.C20PEncAlgorithm.name
19+
authlib.jose.rfc7518.AESAlgorithm.description
20+
authlib.jose.rfc7518.AESAlgorithm.name
21+
authlib.jose.rfc7518.ECDHESAlgorithm.description
22+
authlib.jose.rfc7518.ECDHESAlgorithm.name
23+
authlib.jose.rfc7518.jwe_algs.AESAlgorithm.description
24+
authlib.jose.rfc7518.jwe_algs.AESAlgorithm.name
25+
authlib.jose.rfc7518.jwe_algs.AESGCMAlgorithm.description
26+
authlib.jose.rfc7518.jwe_algs.AESGCMAlgorithm.name
27+
authlib.jose.rfc7518.jwe_algs.ECDHESAlgorithm.description
28+
authlib.jose.rfc7518.jwe_algs.ECDHESAlgorithm.name
29+
authlib.jose.rfc7518.jwe_algs.RSAAlgorithm.description
30+
authlib.jose.rfc7518.jwe_algs.RSAAlgorithm.name
3431

3532
# Re-exports of hashlib functions whose signatures changed in Python 3.13.4.
3633
# (Remove once 3.13.4 is consistently available)
@@ -65,3 +62,15 @@ authlib.oauth2.rfc8628.device_code.DeviceCodeGrant.create_token_response
6562
authlib.oidc.core.OpenIDImplicitGrant.validate_consent_request
6663
authlib.oidc.core.grants.OpenIDImplicitGrant.validate_consent_request
6764
authlib.oidc.core.grants.implicit.OpenIDImplicitGrant.validate_consent_request
65+
66+
# Exclude integrations dirs:
67+
authlib.integrations.django_client
68+
authlib.integrations.django_oauth1
69+
authlib.integrations.django_oauth2
70+
authlib.integrations.flask_client
71+
authlib.integrations.flask_oauth1
72+
authlib.integrations.flask_oauth2
73+
authlib.integrations.httpx_client
74+
authlib.integrations.requests_client
75+
authlib.integrations.sqla_oauth2
76+
authlib.integrations.starlette_client

stubs/Authlib/METADATA.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
version = "~= 1.6.0"
22
upstream_repository = "https://github.com/lepture/authlib"
33
requires = ["cryptography"]
4-
partial_stub = true
5-
6-
[tool.stubtest]
7-
ignore_missing_stub = true

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
from logging import Logger
2+
13
from authlib.integrations.base_client.sync_app import OAuth1Base, OAuth2Base
24

5+
log: Logger
6+
37
__all__ = ["AsyncOAuth1Mixin", "AsyncOAuth2Mixin"]
48

59
class AsyncOAuth1Mixin(OAuth1Base):

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from _typeshed import Incomplete
2+
from logging import Logger
3+
4+
log: Logger
25

36
class BaseApp:
47
client_cls: Incomplete

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterable
3+
from typing import ClassVar
24

35
from authlib.jose.rfc7516 import JWEAlgorithmWithTagAwareKeyAgreement
46

57
class ECDH1PUAlgorithm(JWEAlgorithmWithTagAwareKeyAgreement):
6-
EXTRA_HEADERS: Incomplete
8+
EXTRA_HEADERS: ClassVar[Iterable[str]]
79
ALLOWED_KEY_CLS: Incomplete
810
name: str
911
description: str

stubs/Authlib/authlib/jose/rfc7516/models.pyi

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from _typeshed import Incomplete
22
from abc import ABCMeta
3+
from collections.abc import Iterable
4+
from typing import ClassVar
35

46
class JWEAlgorithmBase(metaclass=ABCMeta):
5-
EXTRA_HEADERS: Incomplete
6-
name: Incomplete
7-
description: Incomplete
7+
EXTRA_HEADERS: ClassVar[Iterable[str] | None]
8+
name: str | None
9+
description: str | None
810
algorithm_type: str
911
algorithm_location: str
1012
def prepare_key(self, raw_data) -> None: ...
@@ -21,8 +23,8 @@ class JWEAlgorithmWithTagAwareKeyAgreement(JWEAlgorithmBase, metaclass=ABCMeta):
2123
def unwrap(self, enc_alg, ek, headers, key, sender_key, tag=None) -> None: ...
2224

2325
class JWEEncAlgorithm:
24-
name: Incomplete
25-
description: Incomplete
26+
name: str | None
27+
description: str | None
2628
algorithm_type: str
2729
algorithm_location: str
2830
IV_SIZE: Incomplete

stubs/Authlib/authlib/jose/rfc7517/asymmetric_key.pyi

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from _typeshed import Incomplete
2+
from typing import ClassVar
23

34
from authlib.jose.rfc7517 import Key
45

56
class AsymmetricKey(Key):
6-
PUBLIC_KEY_FIELDS: Incomplete
7-
PRIVATE_KEY_FIELDS: Incomplete
8-
PRIVATE_KEY_CLS = Incomplete
9-
PUBLIC_KEY_CLS = Incomplete
10-
SSH_PUBLIC_PREFIX: bytes
7+
PUBLIC_KEY_FIELDS: ClassVar[list[str]]
8+
PRIVATE_KEY_FIELDS: ClassVar[list[str]]
9+
PRIVATE_KEY_CLS: ClassVar[type | tuple[type, ...]]
10+
PUBLIC_KEY_CLS: ClassVar[type | tuple[type, ...]]
11+
SSH_PUBLIC_PREFIX: ClassVar[bytes]
1112
private_key: Incomplete
1213
public_key: Incomplete
1314
def __init__(self, private_key=None, public_key=None, options=None) -> None: ...
@@ -18,10 +19,10 @@ class AsymmetricKey(Key):
1819
def get_private_key(self): ...
1920
def load_raw_key(self) -> None: ...
2021
def load_dict_key(self) -> None: ...
21-
def dumps_private_key(self) -> None: ...
22-
def dumps_public_key(self) -> None: ...
23-
def load_private_key(self) -> None: ...
24-
def load_public_key(self) -> None: ...
22+
def dumps_private_key(self): ...
23+
def dumps_public_key(self): ...
24+
def load_private_key(self): ...
25+
def load_public_key(self): ...
2526
def as_dict(self, is_private: bool = False, **params): ...
2627
def as_key(self, is_private: bool = False): ...
2728
def as_bytes(self, encoding=None, is_private: bool = False, password=None): ...

stubs/Authlib/authlib/jose/rfc7517/base_key.pyi

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

34
class Key:
45
kty: str
5-
ALLOWED_PARAMS: Incomplete
6-
PRIVATE_KEY_OPS: Incomplete
7-
PUBLIC_KEY_OPS: Incomplete
8-
REQUIRED_JSON_FIELDS: Incomplete
6+
ALLOWED_PARAMS: ClassVar[list[str]]
7+
PRIVATE_KEY_OPS: ClassVar[list[str]]
8+
PUBLIC_KEY_OPS: ClassVar[list[str]]
9+
REQUIRED_JSON_FIELDS: ClassVar[list[str]]
910
options: Incomplete
1011
def __init__(self, options=None) -> None: ...
1112
@property
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
from _typeshed import Incomplete
2+
from typing import ClassVar
23

34
from authlib.jose.rfc7517 import AsymmetricKey
4-
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKeyWithSerialization, EllipticCurvePublicKey
5+
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey, EllipticCurvePublicKey
56

67
class ECKey(AsymmetricKey):
78
kty: str
89
DSS_CURVES: Incomplete
910
CURVES_DSS: Incomplete
10-
REQUIRED_JSON_FIELDS: Incomplete
11+
REQUIRED_JSON_FIELDS: ClassVar[list[str]]
1112
PUBLIC_KEY_FIELDS = REQUIRED_JSON_FIELDS
12-
PRIVATE_KEY_FIELDS: Incomplete
13-
PUBLIC_KEY_CLS = EllipticCurvePublicKey
14-
PRIVATE_KEY_CLS = EllipticCurvePrivateKeyWithSerialization
15-
SSH_PUBLIC_PREFIX: bytes
13+
PRIVATE_KEY_FIELDS: ClassVar[list[str]]
14+
PUBLIC_KEY_CLS: ClassVar[type]
15+
PRIVATE_KEY_CLS: ClassVar[type]
16+
SSH_PUBLIC_PREFIX: ClassVar[bytes]
1617
def exchange_shared_key(self, pubkey): ...
1718
@property
1819
def curve_key_size(self): ...
19-
def load_private_key(self): ...
20-
def load_public_key(self): ...
21-
def dumps_private_key(self): ...
22-
def dumps_public_key(self): ...
20+
def load_private_key(self) -> EllipticCurvePrivateKey: ...
21+
def load_public_key(self) -> EllipticCurvePublicKey: ...
22+
def dumps_private_key(self) -> dict[str, str]: ...
23+
def dumps_public_key(self) -> dict[str, str]: ...
2324
@classmethod
2425
def generate_key(cls, crv: str = "P-256", options=None, is_private: bool = False) -> ECKey: ...

stubs/Authlib/authlib/jose/rfc7518/jwe_algs.pyi

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterable
3+
from typing import ClassVar, Final
24

35
from authlib.jose.rfc7516 import JWEAlgorithm
46

@@ -12,8 +14,8 @@ class DirectAlgorithm(JWEAlgorithm):
1214

1315
class RSAAlgorithm(JWEAlgorithm):
1416
key_size: int
15-
name: Incomplete
16-
description: Incomplete
17+
name: str
18+
description: str
1719
padding: Incomplete
1820
def __init__(self, name, description, pad_fn) -> None: ...
1921
def prepare_key(self, raw_data): ...
@@ -22,8 +24,8 @@ class RSAAlgorithm(JWEAlgorithm):
2224
def unwrap(self, enc_alg, ek, headers, key): ...
2325

2426
class AESAlgorithm(JWEAlgorithm):
25-
name: Incomplete
26-
description: Incomplete
27+
name: str
28+
description: str
2729
key_size: Incomplete
2830
def __init__(self, key_size) -> None: ...
2931
def prepare_key(self, raw_data): ...
@@ -33,9 +35,9 @@ class AESAlgorithm(JWEAlgorithm):
3335
def unwrap(self, enc_alg, ek, headers, key): ...
3436

3537
class AESGCMAlgorithm(JWEAlgorithm):
36-
EXTRA_HEADERS: Incomplete
37-
name: Incomplete
38-
description: Incomplete
38+
EXTRA_HEADERS: ClassVar[Iterable[str]]
39+
name: str
40+
description: str
3941
key_size: Incomplete
4042
def __init__(self, key_size) -> None: ...
4143
def prepare_key(self, raw_data): ...
@@ -44,7 +46,7 @@ class AESGCMAlgorithm(JWEAlgorithm):
4446
def unwrap(self, enc_alg, ek, headers, key): ...
4547

4648
class ECDHESAlgorithm(JWEAlgorithm):
47-
EXTRA_HEADERS: Incomplete
49+
EXTRA_HEADERS: ClassVar[Iterable[str]]
4850
ALLOWED_KEY_CLS = Incomplete
4951
name: str
5052
description: str
@@ -61,4 +63,4 @@ class ECDHESAlgorithm(JWEAlgorithm):
6163

6264
def u32be_len_input(s, base64: bool = False): ...
6365

64-
JWE_ALG_ALGORITHMS: Incomplete
66+
JWE_ALG_ALGORITHMS: Final[list[JWEAlgorithm]]

0 commit comments

Comments
 (0)