From 0a02a7dacf8578ef77991663bbfbfa8770c8f952 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Wed, 28 Dec 2022 11:33:22 +0100 Subject: Replace more deprecated `abstractproperty` (#7944) --- pyproject.toml | 1 - src/cryptography/hazmat/primitives/_asymmetric.py | 3 ++- src/cryptography/hazmat/primitives/_cipheralgorithm.py | 12 ++++++++---- src/cryptography/hazmat/primitives/asymmetric/dh.py | 6 ++++-- src/cryptography/hazmat/primitives/hashes.py | 12 ++++++++---- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e099c2957..c98a37054 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,6 @@ tests =[ [tool.coverage.report] exclude_lines = [ "@abc.abstractmethod", - "@abc.abstractproperty", "@typing.overload", "if typing.TYPE_CHECKING", ] diff --git a/src/cryptography/hazmat/primitives/_asymmetric.py b/src/cryptography/hazmat/primitives/_asymmetric.py index c6862d931..fb815a0e9 100644 --- a/src/cryptography/hazmat/primitives/_asymmetric.py +++ b/src/cryptography/hazmat/primitives/_asymmetric.py @@ -9,7 +9,8 @@ import abc class AsymmetricPadding(metaclass=abc.ABCMeta): - @abc.abstractproperty + @property + @abc.abstractmethod def name(self) -> str: """ A string naming this padding (e.g. "PSS", "PKCS1"). diff --git a/src/cryptography/hazmat/primitives/_cipheralgorithm.py b/src/cryptography/hazmat/primitives/_cipheralgorithm.py index 6e6a79c11..138a104e2 100644 --- a/src/cryptography/hazmat/primitives/_cipheralgorithm.py +++ b/src/cryptography/hazmat/primitives/_cipheralgorithm.py @@ -10,19 +10,22 @@ import typing class CipherAlgorithm(metaclass=abc.ABCMeta): - @abc.abstractproperty + @property + @abc.abstractmethod def name(self) -> str: """ A string naming this mode (e.g. "AES", "Camellia"). """ - @abc.abstractproperty + @property + @abc.abstractmethod def key_sizes(self) -> typing.FrozenSet[int]: """ Valid key sizes for this algorithm in bits """ - @abc.abstractproperty + @property + @abc.abstractmethod def key_size(self) -> int: """ The size of the key being used as an integer in bits (e.g. 128, 256). @@ -32,7 +35,8 @@ class CipherAlgorithm(metaclass=abc.ABCMeta): class BlockCipherAlgorithm(metaclass=abc.ABCMeta): key: bytes - @abc.abstractproperty + @property + @abc.abstractmethod def block_size(self) -> int: """ The size of a block as an integer in bits (e.g. 64, 128). diff --git a/src/cryptography/hazmat/primitives/asymmetric/dh.py b/src/cryptography/hazmat/primitives/asymmetric/dh.py index bbdd485cd..33de0e551 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/dh.py +++ b/src/cryptography/hazmat/primitives/asymmetric/dh.py @@ -170,7 +170,8 @@ DHParametersWithSerialization = DHParameters class DHPublicKey(metaclass=abc.ABCMeta): - @abc.abstractproperty + @property + @abc.abstractmethod def key_size(self) -> int: """ The bit length of the prime modulus. @@ -203,7 +204,8 @@ DHPublicKeyWithSerialization = DHPublicKey class DHPrivateKey(metaclass=abc.ABCMeta): - @abc.abstractproperty + @property + @abc.abstractmethod def key_size(self) -> int: """ The bit length of the prime modulus. diff --git a/src/cryptography/hazmat/primitives/hashes.py b/src/cryptography/hazmat/primitives/hashes.py index 440b1a3e9..330c08dfa 100644 --- a/src/cryptography/hazmat/primitives/hashes.py +++ b/src/cryptography/hazmat/primitives/hashes.py @@ -10,19 +10,22 @@ from cryptography.exceptions import AlreadyFinalized class HashAlgorithm(metaclass=abc.ABCMeta): - @abc.abstractproperty + @property + @abc.abstractmethod def name(self) -> str: """ A string naming this algorithm (e.g. "sha256", "md5"). """ - @abc.abstractproperty + @property + @abc.abstractmethod def digest_size(self) -> int: """ The size of the resulting digest in bytes. """ - @abc.abstractproperty + @property + @abc.abstractmethod def block_size(self) -> typing.Optional[int]: """ The internal block size of the hash function, or None if the hash @@ -31,7 +34,8 @@ class HashAlgorithm(metaclass=abc.ABCMeta): class HashContext(metaclass=abc.ABCMeta): - @abc.abstractproperty + @property + @abc.abstractmethod def algorithm(self) -> HashAlgorithm: """ A HashAlgorithm that will be used by this context. -- cgit v1.2.1