diff --git a/stubs/cryptography/cryptography/fernet.pyi b/stubs/cryptography/cryptography/fernet.pyi index 2eb1e189b..3e1be3d07 100644 --- a/stubs/cryptography/cryptography/fernet.pyi +++ b/stubs/cryptography/cryptography/fernet.pyi @@ -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. diff --git a/stubs/cryptography/cryptography/hazmat/bindings/openssl/binding.pyi b/stubs/cryptography/cryptography/hazmat/bindings/openssl/binding.pyi index 51c967bee..6b6c6e81d 100644 --- a/stubs/cryptography/cryptography/hazmat/bindings/openssl/binding.pyi +++ b/stubs/cryptography/cryptography/hazmat/bindings/openssl/binding.pyi @@ -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: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dh.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dh.pyi index 7846f75b0..5ea447cb3 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dh.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dh.pyi @@ -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 diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi index db9f19153..364376cc6 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/dsa.pyi @@ -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 diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/ec.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/ec.pyi index a04af595f..fb6e7457e 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/ec.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/ec.pyi @@ -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): ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/padding.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/padding.pyi index bb1781c13..b2d70c5c7 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/padding.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/padding.pyi @@ -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): diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi index 958fc71f8..2fe8886d2 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/rsa.pyi @@ -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: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/utils.pyi b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/utils.pyi index 199bfc8ea..0ab7f47e1 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/utils.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/asymmetric/utils.pyi @@ -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: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/__init__.pyi b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/__init__.pyi index f75a32cc5..c69bde2b0 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/__init__.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/__init__.pyi @@ -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: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi index c6552a228..909f701d9 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/ciphers/aead.pyi @@ -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: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi b/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi index ae05822a9..4be367a7a 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/cmac.pyi @@ -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: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi b/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi index 102ec390c..768a9ecc5 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/hmac.pyi @@ -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: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/padding.pyi b/stubs/cryptography/cryptography/hazmat/primitives/padding.pyi index 7a9d5a8e2..fd5a2b173 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/padding.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/padding.pyi @@ -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: ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/poly1305.pyi b/stubs/cryptography/cryptography/hazmat/primitives/poly1305.pyi index 886f67027..a854709f5 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/poly1305.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/poly1305.pyi @@ -1,4 +1,4 @@ -class Poly1305(object): +class Poly1305: def __init__(self, key: bytes) -> None: ... def finalize(self) -> bytes: ... @classmethod diff --git a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi index 2cb453061..1c0272cbc 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/hotp.pyi @@ -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 = ... ): ... diff --git a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi index f6ba23e46..37c4c0ef9 100644 --- a/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi +++ b/stubs/cryptography/cryptography/hazmat/primitives/twofactor/totp.pyi @@ -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, diff --git a/stubs/cryptography/cryptography/x509/__init__.pyi b/stubs/cryptography/cryptography/x509/__init__.pyi index e9db89a0f..bf4385ab0 100644 --- a/stubs/cryptography/cryptography/x509/__init__.pyi +++ b/stubs/cryptography/cryptography/x509/__init__.pyi @@ -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]: ... diff --git a/stubs/paramiko/paramiko/pipe.pyi b/stubs/paramiko/paramiko/pipe.pyi index eb7274903..e9b1635ec 100644 --- a/stubs/paramiko/paramiko/pipe.pyi +++ b/stubs/paramiko/paramiko/pipe.pyi @@ -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: ... diff --git a/tests/check_new_syntax.py b/tests/check_new_syntax.py index 469414853..f6945a003 100755 --- a/tests/check_new_syntax.py +++ b/tests/check_new_syntax.py @@ -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):