mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Remove explicit inheritance from object (#7468)
This commit is contained in:
@@ -2,7 +2,7 @@ from typing import Text
|
||||
|
||||
class InvalidToken(Exception): ...
|
||||
|
||||
class Fernet(object):
|
||||
class Fernet:
|
||||
def __init__(self, key: bytes | Text) -> None: ...
|
||||
def decrypt(self, token: bytes, ttl: int | None = ...) -> bytes: ...
|
||||
# decrypt_at_time accepts None ttl at runtime but it's an implementtion detail and it doesn't really
|
||||
@@ -15,7 +15,7 @@ class Fernet(object):
|
||||
@classmethod
|
||||
def generate_key(cls) -> bytes: ...
|
||||
|
||||
class MultiFernet(object):
|
||||
class MultiFernet:
|
||||
def __init__(self, fernets: list[Fernet]) -> None: ...
|
||||
def decrypt(self, token: bytes, ttl: int | None = ...) -> bytes: ...
|
||||
# See a note above on the typing of the ttl parameter.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
class Binding(object):
|
||||
class Binding:
|
||||
ffi: Any | None
|
||||
lib: Any | None
|
||||
def init_static_locks(self) -> None: ...
|
||||
|
||||
@@ -19,7 +19,7 @@ class DHParameters(metaclass=ABCMeta):
|
||||
|
||||
DHParametersWithSerialization = DHParameters
|
||||
|
||||
class DHParameterNumbers(object):
|
||||
class DHParameterNumbers:
|
||||
@property
|
||||
def p(self) -> int: ...
|
||||
@property
|
||||
@@ -46,7 +46,7 @@ class DHPrivateKeyWithSerialization(DHPrivateKey):
|
||||
@abstractmethod
|
||||
def private_numbers(self) -> DHPrivateNumbers: ...
|
||||
|
||||
class DHPrivateNumbers(object):
|
||||
class DHPrivateNumbers:
|
||||
@property
|
||||
def public_numbers(self) -> DHPublicNumbers: ...
|
||||
@property
|
||||
@@ -67,7 +67,7 @@ class DHPublicKey(metaclass=ABCMeta):
|
||||
|
||||
DHPublicKeyWithSerialization = DHPublicKey
|
||||
|
||||
class DHPublicNumbers(object):
|
||||
class DHPublicNumbers:
|
||||
@property
|
||||
def parameter_numbers(self) -> DHParameterNumbers: ...
|
||||
@property
|
||||
|
||||
@@ -14,7 +14,7 @@ class DSAParametersWithNumbers(DSAParameters):
|
||||
@abstractmethod
|
||||
def parameter_numbers(self) -> DSAParameterNumbers: ...
|
||||
|
||||
class DSAParameterNumbers(object):
|
||||
class DSAParameterNumbers:
|
||||
@property
|
||||
def p(self) -> int: ...
|
||||
@property
|
||||
@@ -43,7 +43,7 @@ class DSAPrivateKeyWithSerialization(DSAPrivateKey):
|
||||
@abstractmethod
|
||||
def private_numbers(self) -> DSAPrivateNumbers: ...
|
||||
|
||||
class DSAPrivateNumbers(object):
|
||||
class DSAPrivateNumbers:
|
||||
@property
|
||||
def x(self) -> int: ...
|
||||
@property
|
||||
@@ -65,7 +65,7 @@ class DSAPublicKey(metaclass=ABCMeta):
|
||||
|
||||
DSAPublicKeyWithSerialization = DSAPublicKey
|
||||
|
||||
class DSAPublicNumbers(object):
|
||||
class DSAPublicNumbers:
|
||||
@property
|
||||
def y(self) -> int: ...
|
||||
@property
|
||||
|
||||
@@ -93,7 +93,7 @@ class SECT571R1(EllipticCurve):
|
||||
key_size: int = ...
|
||||
name: str = ...
|
||||
|
||||
class EllipticCurveOID(object):
|
||||
class EllipticCurveOID:
|
||||
SECP192R1: ClassVar[ObjectIdentifier]
|
||||
SECP224R1: ClassVar[ObjectIdentifier]
|
||||
SECP256K1: ClassVar[ObjectIdentifier]
|
||||
@@ -136,7 +136,7 @@ class EllipticCurvePrivateKeyWithSerialization(EllipticCurvePrivateKey):
|
||||
@abstractmethod
|
||||
def private_numbers(self) -> EllipticCurvePrivateNumbers: ...
|
||||
|
||||
class EllipticCurvePrivateNumbers(object):
|
||||
class EllipticCurvePrivateNumbers:
|
||||
@property
|
||||
def private_value(self) -> int: ...
|
||||
@property
|
||||
@@ -166,7 +166,7 @@ class EllipticCurvePublicKey(metaclass=ABCMeta):
|
||||
|
||||
EllipticCurvePublicKeyWithSerialization = EllipticCurvePublicKey
|
||||
|
||||
class EllipticCurvePublicNumbers(object):
|
||||
class EllipticCurvePublicNumbers:
|
||||
@property
|
||||
def curve(self) -> EllipticCurve: ...
|
||||
@property
|
||||
@@ -183,7 +183,7 @@ class EllipticCurveSignatureAlgorithm(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def algorithm(self) -> HashAlgorithm | Prehashed: ...
|
||||
|
||||
class ECDH(object): ...
|
||||
class ECDH: ...
|
||||
|
||||
class ECDSA(EllipticCurveSignatureAlgorithm):
|
||||
def __init__(self, algorithm: HashAlgorithm | Prehashed): ...
|
||||
|
||||
@@ -8,7 +8,7 @@ class AsymmetricPadding(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def name(self) -> str: ...
|
||||
|
||||
class MGF1(object):
|
||||
class MGF1:
|
||||
def __init__(self, algorithm: HashAlgorithm) -> None: ...
|
||||
|
||||
class OAEP(AsymmetricPadding):
|
||||
|
||||
@@ -53,7 +53,7 @@ def rsa_crt_dmp1(private_exponent: int, p: int) -> int: ...
|
||||
def rsa_crt_dmq1(private_exponent: int, q: int) -> int: ...
|
||||
def rsa_recover_prime_factors(n: int, e: int, d: int) -> tuple[int, int]: ...
|
||||
|
||||
class RSAPrivateNumbers(object):
|
||||
class RSAPrivateNumbers:
|
||||
def __init__(self, p: int, q: int, d: int, dmp1: int, dmq1: int, iqmp: int, public_numbers: RSAPublicNumbers) -> None: ...
|
||||
@property
|
||||
def p(self) -> int: ...
|
||||
@@ -71,7 +71,7 @@ class RSAPrivateNumbers(object):
|
||||
def public_numbers(self) -> RSAPublicNumbers: ...
|
||||
def private_key(self, backend: RSABackend | None = ...) -> RSAPrivateKey: ...
|
||||
|
||||
class RSAPublicNumbers(object):
|
||||
class RSAPublicNumbers:
|
||||
def __init__(self, e: int, n: int) -> None: ...
|
||||
@property
|
||||
def e(self) -> int: ...
|
||||
|
||||
@@ -3,7 +3,7 @@ from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
def decode_dss_signature(signature: bytes) -> tuple[int, int]: ...
|
||||
def encode_dss_signature(r: int, s: int) -> bytes: ...
|
||||
|
||||
class Prehashed(object):
|
||||
class Prehashed:
|
||||
_algorithm: HashAlgorithm # undocumented
|
||||
_digest_size: int # undocumented
|
||||
def __init__(self, algorithm: HashAlgorithm) -> None: ...
|
||||
|
||||
@@ -21,7 +21,7 @@ class BlockCipherAlgorithm(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def block_size(self) -> int: ...
|
||||
|
||||
class Cipher(object):
|
||||
class Cipher:
|
||||
def __init__(self, algorithm: CipherAlgorithm, mode: Mode | None, backend: CipherBackend | None = ...) -> None: ...
|
||||
def decryptor(self) -> CipherContext: ...
|
||||
def encryptor(self) -> CipherContext: ...
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
class AESCCM(object):
|
||||
class AESCCM:
|
||||
def __init__(self, key: bytes, tag_length: int | None) -> None: ...
|
||||
def decrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ...
|
||||
def encrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ...
|
||||
@classmethod
|
||||
def generate_key(cls, bit_length: int) -> bytes: ...
|
||||
|
||||
class AESGCM(object):
|
||||
class AESGCM:
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
def decrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ...
|
||||
def encrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ...
|
||||
@classmethod
|
||||
def generate_key(cls, bit_length: int) -> bytes: ...
|
||||
|
||||
class ChaCha20Poly1305(object):
|
||||
class ChaCha20Poly1305:
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
def decrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ...
|
||||
def encrypt(self, nonce: bytes, data: bytes, associated_data: bytes | None) -> bytes: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from cryptography.hazmat.backends.interfaces import CMACBackend
|
||||
from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm
|
||||
|
||||
class CMAC(object):
|
||||
class CMAC:
|
||||
def __init__(self, algorithm: BlockCipherAlgorithm, backend: CMACBackend | None = ...) -> None: ...
|
||||
def copy(self) -> CMAC: ...
|
||||
def finalize(self) -> bytes: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from cryptography.hazmat.backends.interfaces import HMACBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
|
||||
class HMAC(object):
|
||||
class HMAC:
|
||||
def __init__(self, key: bytes, algorithm: HashAlgorithm, backend: HMACBackend | None = ...) -> None: ...
|
||||
def copy(self) -> HMAC: ...
|
||||
def finalize(self) -> bytes: ...
|
||||
|
||||
@@ -6,12 +6,12 @@ class PaddingContext(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def update(self, data: bytes) -> bytes: ...
|
||||
|
||||
class ANSIX923(object):
|
||||
class ANSIX923:
|
||||
def __init__(self, block_size: int) -> None: ...
|
||||
def padder(self) -> PaddingContext: ...
|
||||
def unpadder(self) -> PaddingContext: ...
|
||||
|
||||
class PKCS7(object):
|
||||
class PKCS7:
|
||||
def __init__(self, block_size: int) -> None: ...
|
||||
def padder(self) -> PaddingContext: ...
|
||||
def unpadder(self) -> PaddingContext: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Poly1305(object):
|
||||
class Poly1305:
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
def finalize(self) -> bytes: ...
|
||||
@classmethod
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from cryptography.hazmat.backends.interfaces import HMACBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
|
||||
class HOTP(object):
|
||||
class HOTP:
|
||||
def __init__(
|
||||
self, key: bytes, length: int, algorithm: HashAlgorithm, backend: HMACBackend | None = ..., enforce_key_length: bool = ...
|
||||
): ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from cryptography.hazmat.backends.interfaces import HMACBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
|
||||
class TOTP(object):
|
||||
class TOTP:
|
||||
def __init__(
|
||||
self,
|
||||
key: bytes,
|
||||
|
||||
@@ -14,16 +14,16 @@ from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPubl
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
from cryptography.hazmat.primitives.serialization import Encoding
|
||||
|
||||
class ObjectIdentifier(object):
|
||||
class ObjectIdentifier:
|
||||
dotted_string: str
|
||||
def __init__(self, dotted_string: str) -> None: ...
|
||||
|
||||
class CRLEntryExtensionOID(object):
|
||||
class CRLEntryExtensionOID:
|
||||
CERTIFICATE_ISSUER: ClassVar[ObjectIdentifier]
|
||||
CRL_REASON: ClassVar[ObjectIdentifier]
|
||||
INVALIDITY_DATE: ClassVar[ObjectIdentifier]
|
||||
|
||||
class ExtensionOID(object):
|
||||
class ExtensionOID:
|
||||
AUTHORITY_INFORMATION_ACCESS: ClassVar[ObjectIdentifier]
|
||||
AUTHORITY_KEY_IDENTIFIER: ClassVar[ObjectIdentifier]
|
||||
BASIC_CONSTRAINTS: ClassVar[ObjectIdentifier]
|
||||
@@ -49,7 +49,7 @@ class ExtensionOID(object):
|
||||
SUBJECT_KEY_IDENTIFIER: ClassVar[ObjectIdentifier]
|
||||
TLS_FEATURE: ClassVar[ObjectIdentifier]
|
||||
|
||||
class NameOID(object):
|
||||
class NameOID:
|
||||
BUSINESS_CATEGORY: ClassVar[ObjectIdentifier]
|
||||
COMMON_NAME: ClassVar[ObjectIdentifier]
|
||||
COUNTRY_NAME: ClassVar[ObjectIdentifier]
|
||||
@@ -75,10 +75,10 @@ class NameOID(object):
|
||||
USER_ID: ClassVar[ObjectIdentifier]
|
||||
X500_UNIQUE_IDENTIFIER: ClassVar[ObjectIdentifier]
|
||||
|
||||
class OCSPExtensionOID(object):
|
||||
class OCSPExtensionOID:
|
||||
NONCE: ClassVar[ObjectIdentifier]
|
||||
|
||||
class SignatureAlgorithmOID(object):
|
||||
class SignatureAlgorithmOID:
|
||||
DSA_WITH_SHA1: ClassVar[ObjectIdentifier]
|
||||
DSA_WITH_SHA224: ClassVar[ObjectIdentifier]
|
||||
DSA_WITH_SHA256: ClassVar[ObjectIdentifier]
|
||||
@@ -97,7 +97,7 @@ class SignatureAlgorithmOID(object):
|
||||
RSA_WITH_SHA384: ClassVar[ObjectIdentifier]
|
||||
RSA_WITH_SHA512: ClassVar[ObjectIdentifier]
|
||||
|
||||
class ExtendedKeyUsageOID(object):
|
||||
class ExtendedKeyUsageOID:
|
||||
SERVER_AUTH: ClassVar[ObjectIdentifier]
|
||||
CLIENT_AUTH: ClassVar[ObjectIdentifier]
|
||||
CODE_SIGNING: ClassVar[ObjectIdentifier]
|
||||
@@ -106,19 +106,19 @@ class ExtendedKeyUsageOID(object):
|
||||
OCSP_SIGNING: ClassVar[ObjectIdentifier]
|
||||
ANY_EXTENDED_KEY_USAGE: ClassVar[ObjectIdentifier]
|
||||
|
||||
class NameAttribute(object):
|
||||
class NameAttribute:
|
||||
oid: ObjectIdentifier
|
||||
value: Text
|
||||
def __init__(self, oid: ObjectIdentifier, value: Text) -> None: ...
|
||||
def rfc4514_string(self) -> str: ...
|
||||
|
||||
class RelativeDistinguishedName(object):
|
||||
class RelativeDistinguishedName:
|
||||
def __init__(self, attributes: list[NameAttribute]) -> None: ...
|
||||
def __iter__(self) -> Generator[NameAttribute, None, None]: ...
|
||||
def get_attributes_for_oid(self, oid: ObjectIdentifier) -> list[NameAttribute]: ...
|
||||
def rfc4514_string(self) -> str: ...
|
||||
|
||||
class Name(object):
|
||||
class Name:
|
||||
rdns: list[RelativeDistinguishedName]
|
||||
def __init__(self, attributes: Sequence[NameAttribute | RelativeDistinguishedName]) -> None: ...
|
||||
def __iter__(self) -> Generator[NameAttribute, None, None]: ...
|
||||
@@ -150,7 +150,7 @@ class Certificate(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def public_key(self) -> DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey: ...
|
||||
|
||||
class CertificateBuilder(object):
|
||||
class CertificateBuilder:
|
||||
def __init__(
|
||||
self,
|
||||
issuer_name: Name | None = ...,
|
||||
@@ -197,7 +197,7 @@ class CertificateRevocationList(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def public_bytes(self, encoding: Encoding) -> bytes: ...
|
||||
|
||||
class CertificateRevocationListBuilder(object):
|
||||
class CertificateRevocationListBuilder:
|
||||
def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateRevocationListBuilder: ...
|
||||
def add_revoked_certificate(self, revoked_certificate: RevokedCertificate) -> CertificateRevocationListBuilder: ...
|
||||
def issuer_name(self, name: Name) -> CertificateRevocationListBuilder: ...
|
||||
@@ -223,7 +223,7 @@ class CertificateSigningRequest(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def public_key(self) -> DSAPublicKey | Ed25519PublicKey | Ed448PublicKey | EllipticCurvePublicKey | RSAPublicKey: ...
|
||||
|
||||
class CertificateSigningRequestBuilder(object):
|
||||
class CertificateSigningRequestBuilder:
|
||||
def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateSigningRequestBuilder: ...
|
||||
def subject_name(self, name: Name) -> CertificateSigningRequestBuilder: ...
|
||||
def sign(
|
||||
@@ -238,7 +238,7 @@ class RevokedCertificate(metaclass=ABCMeta):
|
||||
revocation_date: datetime.datetime
|
||||
serial_number: int
|
||||
|
||||
class RevokedCertificateBuilder(object):
|
||||
class RevokedCertificateBuilder:
|
||||
def add_extension(self, extension: ExtensionType, critical: bool) -> RevokedCertificateBuilder: ...
|
||||
def build(self, backend: X509Backend | None = ...) -> RevokedCertificate: ...
|
||||
def revocation_date(self, time: datetime.datetime) -> RevokedCertificateBuilder: ...
|
||||
@@ -290,7 +290,7 @@ class Extension(Generic[_T]):
|
||||
oid: ObjectIdentifier
|
||||
value: _T
|
||||
|
||||
class Extensions(object):
|
||||
class Extensions:
|
||||
def __init__(self, general_names: list[Extension[Any]]) -> None: ...
|
||||
def __iter__(self) -> Generator[Extension[Any], None, None]: ...
|
||||
def get_extension_for_oid(self, oid: ObjectIdentifier) -> Extension[Any]: ...
|
||||
|
||||
@@ -11,7 +11,7 @@ class _Pipe(_BasePipe, Protocol):
|
||||
|
||||
def make_pipe() -> _Pipe: ...
|
||||
|
||||
class PosixPipe(object):
|
||||
class PosixPipe:
|
||||
def __init__(self) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def fileno(self) -> int: ...
|
||||
@@ -19,7 +19,7 @@ class PosixPipe(object):
|
||||
def set(self) -> None: ...
|
||||
def set_forever(self) -> None: ...
|
||||
|
||||
class WindowsPipe(object):
|
||||
class WindowsPipe:
|
||||
def __init__(self) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def fileno(self) -> int: ...
|
||||
|
||||
@@ -46,13 +46,11 @@ def check_new_syntax(tree: ast.AST, path: Path) -> list[str]:
|
||||
|
||||
class ObjectClassdefFinder(ast.NodeVisitor):
|
||||
def visit_ClassDef(self, node: ast.ClassDef) -> None:
|
||||
# Temporarily disable this check for two ex-Python 2 stubs.
|
||||
if "paramiko" not in str(path) and "cryptography" not in str(path):
|
||||
if any(isinstance(base, ast.Name) and base.id == "object" for base in node.bases):
|
||||
errors.append(
|
||||
f"{path}:{node.lineno}: Do not inherit from `object` explicitly, "
|
||||
f"as all classes implicitly inherit from `object` in Python 3"
|
||||
)
|
||||
if any(isinstance(base, ast.Name) and base.id == "object" for base in node.bases):
|
||||
errors.append(
|
||||
f"{path}:{node.lineno}: Do not inherit from `object` explicitly, "
|
||||
f"as all classes implicitly inherit from `object` in Python 3"
|
||||
)
|
||||
self.generic_visit(node)
|
||||
|
||||
class IfFinder(ast.NodeVisitor):
|
||||
|
||||
Reference in New Issue
Block a user