Skip to content

Commit 4f63ff2

Browse files
authored
[jwcrypto] Add JWK.__hash__ and another __init__ overload (#15782)
1 parent fcc86fc commit 4f63ff2

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

stubs/jwcrypto/jwcrypto/jwk.pyi

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,23 @@ class InvalidJWKValue(JWException): ...
104104

105105
class JWK(dict[str, Any]):
106106
unsafe_skip_rsa_key_validation: bool
107+
@overload
108+
def __init__(
109+
self,
110+
*,
111+
generate: Literal["RSA"],
112+
public_exponent: int | None = None,
113+
size: int | None = None,
114+
kid: str | None = None,
115+
alg: str | None = None,
116+
use: _JWKUseSupported | None = None,
117+
key_ops: list[_JWKOperationSupported] | None = None,
118+
) -> None: ...
119+
@overload
120+
def __init__(self, *, generate: Literal["oct", "EC", "OKP"], **kwargs) -> None: ...
121+
@overload
107122
def __init__(self, **kwargs) -> None: ...
108-
# `kty` and the other keyword arguments are passed as `params` to the called generator
109-
# function. The possible arguments depend on the value of `kty`.
110-
# TODO: Add overloads for the individual `kty` values.
123+
# TODO: __init__ may not be typed adequately because keyword arguments depend on the value of generate
111124
@classmethod
112125
@overload
113126
def generate(
@@ -230,6 +243,7 @@ class JWK(dict[str, Any]):
230243
@classmethod
231244
def from_password(cls, password: str) -> Self: ...
232245
def setdefault(self, key: str, default: _T | None = None) -> _T: ...
246+
def __hash__(self) -> int: ... # type: ignore[override]
233247

234248
class JWKSet(dict[Literal["keys"], set[JWK]]):
235249
@overload

0 commit comments

Comments
 (0)