From 223152fa5304594187f6136851b80022adfa6c4b Mon Sep 17 00:00:00 2001 From: Azraei Yusof Date: Tue, 13 May 2025 10:43:49 +0800 Subject: [PATCH 1/2] jwcrypto: Fix export_to_pem password argument --- stubs/jwcrypto/jwcrypto/jwk.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/jwcrypto/jwcrypto/jwk.pyi b/stubs/jwcrypto/jwcrypto/jwk.pyi index 9ec8c3866a41..86cf497e04c0 100644 --- a/stubs/jwcrypto/jwcrypto/jwk.pyi +++ b/stubs/jwcrypto/jwcrypto/jwk.pyi @@ -201,7 +201,7 @@ class JWK(dict[str, Any]): ), ) -> None: ... def import_from_pem(self, data: bytes, password: bytes | None = None, kid: str | None = None) -> None: ... - def export_to_pem(self, private_key: bool = False, password: bool = False) -> bytes: ... + def export_to_pem(self, private_key: bool = False, password: Literal[False] | bytes | None = False) -> bytes: ... @classmethod def from_pyca( cls, From 5b8318c9a3f280d048c104693c862d30b39c20a6 Mon Sep 17 00:00:00 2001 From: Azraei Yusof Date: Wed, 14 May 2025 01:55:23 +0800 Subject: [PATCH 2/2] jwcrypto: refined export_to_pem typing --- stubs/jwcrypto/jwcrypto/jwk.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stubs/jwcrypto/jwcrypto/jwk.pyi b/stubs/jwcrypto/jwcrypto/jwk.pyi index 86cf497e04c0..721b4e892e9b 100644 --- a/stubs/jwcrypto/jwcrypto/jwk.pyi +++ b/stubs/jwcrypto/jwcrypto/jwk.pyi @@ -1,3 +1,4 @@ +from _typeshed import Unused from collections.abc import Callable, Sequence from enum import Enum from typing import Any, Literal, NamedTuple, TypeVar, overload @@ -201,7 +202,10 @@ class JWK(dict[str, Any]): ), ) -> None: ... def import_from_pem(self, data: bytes, password: bytes | None = None, kid: str | None = None) -> None: ... - def export_to_pem(self, private_key: bool = False, password: Literal[False] | bytes | None = False) -> bytes: ... + @overload + def export_to_pem(self, private_key: Literal[False] = False, password: Unused = False) -> bytes: ... + @overload + def export_to_pem(self, private_key: Literal[True], password: bytes | None) -> bytes: ... @classmethod def from_pyca( cls,