summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorikeikeikeike / ikedat / Tatsuo Ikeda <jp.ne.co.jp@gmail.com>2021-12-07 18:58:57 +0900
committerSybren A. Stüvel <sybren@stuvel.eu>2022-01-11 13:57:25 +0100
commit32bfe4007e4284b95a58be9f655c8aee605c712a (patch)
tree4c24f90666450cf00b63bea7be9f931a8790bee6
parent5b377fb093ae3b7e5b1eaeec732ee429488bd662 (diff)
downloadrsa-git-32bfe4007e4284b95a58be9f655c8aee605c712a.tar.gz
Tiny fix to Incompatible types in assignment
-rw-r--r--rsa/key.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/rsa/key.py b/rsa/key.py
index 1284ffc..9491747 100644
--- a/rsa/key.py
+++ b/rsa/key.py
@@ -47,6 +47,9 @@ log = logging.getLogger(__name__)
DEFAULT_EXPONENT = 65537
+T = typing.TypeVar("T", bound="AbstractKey")
+
+
class AbstractKey:
"""Abstract superclass for private and public keys."""
@@ -64,7 +67,7 @@ class AbstractKey:
self.mutex = threading.Lock()
@classmethod
- def _load_pkcs1_pem(cls, keyfile: bytes) -> "AbstractKey":
+ def _load_pkcs1_pem(cls: typing.Type[T], keyfile: bytes) -> T:
"""Loads a key in PKCS#1 PEM format, implement in a subclass.
:param keyfile: contents of a PEM-encoded file that contains
@@ -76,7 +79,7 @@ class AbstractKey:
"""
@classmethod
- def _load_pkcs1_der(cls, keyfile: bytes) -> "AbstractKey":
+ def _load_pkcs1_der(cls: typing.Type[T], keyfile: bytes) -> T:
"""Loads a key in PKCS#1 PEM format, implement in a subclass.
:param keyfile: contents of a DER-encoded file that contains
@@ -102,7 +105,7 @@ class AbstractKey:
"""
@classmethod
- def load_pkcs1(cls, keyfile: bytes, format: str = "PEM") -> "AbstractKey":
+ def load_pkcs1(cls: typing.Type[T], keyfile: bytes, format: str = "PEM") -> T:
"""Loads a key in PKCS#1 DER or PEM format.
:param keyfile: contents of a DER- or PEM-encoded file that contains