From c83166ba7d1476d2782c3413b76c3457dc02660c Mon Sep 17 00:00:00 2001 From: Hsiaoming Yang Date: Wed, 6 Sep 2023 21:24:53 +0900 Subject: [PATCH] fix: adding more type hints --- src/joserfc/rfc7517/models.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/joserfc/rfc7517/models.py b/src/joserfc/rfc7517/models.py index a3f74c7..332a017 100644 --- a/src/joserfc/rfc7517/models.py +++ b/src/joserfc/rfc7517/models.py @@ -17,9 +17,9 @@ ) -GenericKey = t.TypeVar("GenericKey", bound="BaseKey") NativePrivateKey = t.TypeVar("NativePrivateKey") NativePublicKey = t.TypeVar("NativePublicKey") +GenericKey = t.TypeVar("GenericKey", bound="BaseKey[t.Any, t.Any]") class NativeKeyBinding(metaclass=ABCMeta): @@ -44,8 +44,12 @@ def import_from_bytes(cls, value: bytes, password: t.Optional[t.Any] = None) -> pass @staticmethod - def as_bytes(key: GenericKey, encoding=None, private=None, password=None) -> bytes: # pragma: no cover - return key.raw_value + def as_bytes( + key: GenericKey, + encoding: t.Optional[str] = None, + private: t.Optional[bool] = None, + password: t.Optional[str] = None) -> bytes: + raise NotImplementedError() @classmethod def validate_dict_key_registry(cls, dict_key: DictKey, registry: KeyParameterRegistryDict) -> None: @@ -288,10 +292,10 @@ def as_bytes( password: t.Optional[str] = None) -> bytes: return self.binding.as_bytes(self, encoding, private, password) - def as_pem(self, private=None, password=None) -> bytes: + def as_pem(self, private: t.Optional[bool] = None, password: t.Optional[str] = None) -> bytes: return self.as_bytes(private=private, password=password) - def as_der(self, private=None, password=None) -> bytes: + def as_der(self, private: t.Optional[bool] = None, password: t.Optional[str] = None) -> bytes: return self.as_bytes(encoding="DER", private=private, password=password)