@@ -8,7 +8,7 @@ import datetime as dt
88import enum
99import sys
1010from pathlib import Path
11- from typing import NamedTuple , Sequence , Tuple , Union
11+ from typing import NamedTuple , Sequence , Tuple , Type , TypeVar , Union
1212
1313from mbedtls .hashlib import Hash as _Hash
1414from mbedtls .pk import ECC , RSA
@@ -39,18 +39,22 @@ class KeyUsage(enum.IntEnum):
3939def PEM_to_DER (pem : _PEM ) -> _DER : ...
4040def DER_to_PEM (der : _DER , text : str ) -> _PEM : ...
4141
42+ TCertificate = TypeVar ("TCertificate" , bound = Certificate )
43+
4244class Certificate (abc .ABC ):
4345 @classmethod
44- def from_buffer (cls , buffer : bytes ) -> Certificate : ...
46+ def from_buffer (
47+ cls : Type [TCertificate ], buffer : bytes
48+ ) -> TCertificate : ...
4549 @classmethod
4650 @abc .abstractmethod
47- def from_file (cls , path : _Path ) -> Certificate : ...
51+ def from_file (cls : Type [ TCertificate ] , path : _Path ) -> TCertificate : ...
4852 @classmethod
4953 @abc .abstractmethod
50- def from_DER (cls , der : _DER ) -> Certificate : ...
54+ def from_DER (cls : Type [ TCertificate ] , der : _DER ) -> TCertificate : ...
5155 @classmethod
5256 @abc .abstractmethod
53- def from_PEM (cls , pem : _PEM ) -> Certificate : ...
57+ def from_PEM (cls : Type [ TCertificate ] , pem : _PEM ) -> TCertificate : ...
5458 def __hash__ (self ) -> int : ...
5559 def __eq__ (self , other : object ) -> bool : ...
5660 @abc .abstractmethod
@@ -90,7 +94,7 @@ class CRT(Certificate):
9094 @property
9195 def subject (self ) -> str : ...
9296 @property
93- def subject_public_key (self ) -> object : ...
97+ def subject_public_key (self ) -> _PKEY : ...
9498 @property
9599 def key_usage (self ) -> object : ...
96100 @property
0 commit comments