Skip to content

Commit

Permalink
Replace more deprecated abstractproperty (#7944)
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Dec 28, 2022
1 parent c28bfb3 commit 0a02a7d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Expand Up @@ -59,7 +59,6 @@ tests =[
[tool.coverage.report]
exclude_lines = [
"@abc.abstractmethod",
"@abc.abstractproperty",
"@typing.overload",
"if typing.TYPE_CHECKING",
]
Expand Down
3 changes: 2 additions & 1 deletion src/cryptography/hazmat/primitives/_asymmetric.py
Expand Up @@ -9,7 +9,8 @@


class AsymmetricPadding(metaclass=abc.ABCMeta):
@abc.abstractproperty
@property
@abc.abstractmethod
def name(self) -> str:
"""
A string naming this padding (e.g. "PSS", "PKCS1").
Expand Down
12 changes: 8 additions & 4 deletions src/cryptography/hazmat/primitives/_cipheralgorithm.py
Expand Up @@ -10,19 +10,22 @@


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).
Expand All @@ -32,7 +35,8 @@ def key_size(self) -> int:
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).
Expand Down
6 changes: 4 additions & 2 deletions src/cryptography/hazmat/primitives/asymmetric/dh.py
Expand Up @@ -170,7 +170,8 @@ def parameter_numbers(self) -> DHParameterNumbers:


class DHPublicKey(metaclass=abc.ABCMeta):
@abc.abstractproperty
@property
@abc.abstractmethod
def key_size(self) -> int:
"""
The bit length of the prime modulus.
Expand Down Expand Up @@ -203,7 +204,8 @@ def public_bytes(


class DHPrivateKey(metaclass=abc.ABCMeta):
@abc.abstractproperty
@property
@abc.abstractmethod
def key_size(self) -> int:
"""
The bit length of the prime modulus.
Expand Down
12 changes: 8 additions & 4 deletions src/cryptography/hazmat/primitives/hashes.py
Expand Up @@ -10,19 +10,22 @@


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
Expand All @@ -31,7 +34,8 @@ def block_size(self) -> typing.Optional[int]:


class HashContext(metaclass=abc.ABCMeta):
@abc.abstractproperty
@property
@abc.abstractmethod
def algorithm(self) -> HashAlgorithm:
"""
A HashAlgorithm that will be used by this context.
Expand Down

0 comments on commit 0a02a7d

Please sign in to comment.