Skip to content
This repository was archived by the owner on Apr 20, 2025. It is now read-only.

Commit 32bfe40

Browse files
ikeikeikeikesybrenstuvel
authored andcommitted
Tiny fix to Incompatible types in assignment
1 parent 5b377fb commit 32bfe40

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

rsa/key.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
DEFAULT_EXPONENT = 65537
4848

4949

50+
T = typing.TypeVar("T", bound="AbstractKey")
51+
52+
5053
class AbstractKey:
5154
"""Abstract superclass for private and public keys."""
5255

@@ -64,7 +67,7 @@ def __init__(self, n: int, e: int) -> None:
6467
self.mutex = threading.Lock()
6568

6669
@classmethod
67-
def _load_pkcs1_pem(cls, keyfile: bytes) -> "AbstractKey":
70+
def _load_pkcs1_pem(cls: typing.Type[T], keyfile: bytes) -> T:
6871
"""Loads a key in PKCS#1 PEM format, implement in a subclass.
6972
7073
:param keyfile: contents of a PEM-encoded file that contains
@@ -76,7 +79,7 @@ def _load_pkcs1_pem(cls, keyfile: bytes) -> "AbstractKey":
7679
"""
7780

7881
@classmethod
79-
def _load_pkcs1_der(cls, keyfile: bytes) -> "AbstractKey":
82+
def _load_pkcs1_der(cls: typing.Type[T], keyfile: bytes) -> T:
8083
"""Loads a key in PKCS#1 PEM format, implement in a subclass.
8184
8285
:param keyfile: contents of a DER-encoded file that contains
@@ -102,7 +105,7 @@ def _save_pkcs1_der(self) -> bytes:
102105
"""
103106

104107
@classmethod
105-
def load_pkcs1(cls, keyfile: bytes, format: str = "PEM") -> "AbstractKey":
108+
def load_pkcs1(cls: typing.Type[T], keyfile: bytes, format: str = "PEM") -> T:
106109
"""Loads a key in PKCS#1 DER or PEM format.
107110
108111
:param keyfile: contents of a DER- or PEM-encoded file that contains

0 commit comments

Comments
 (0)