Skip to content

Commit 0a02a7d

Browse files
authored
Replace more deprecated abstractproperty (#7944)
1 parent c28bfb3 commit 0a02a7d

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ tests =[
5959
[tool.coverage.report]
6060
exclude_lines = [
6161
"@abc.abstractmethod",
62-
"@abc.abstractproperty",
6362
"@typing.overload",
6463
"if typing.TYPE_CHECKING",
6564
]

src/cryptography/hazmat/primitives/_asymmetric.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010

1111
class AsymmetricPadding(metaclass=abc.ABCMeta):
12-
@abc.abstractproperty
12+
@property
13+
@abc.abstractmethod
1314
def name(self) -> str:
1415
"""
1516
A string naming this padding (e.g. "PSS", "PKCS1").

src/cryptography/hazmat/primitives/_cipheralgorithm.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,22 @@
1010

1111

1212
class CipherAlgorithm(metaclass=abc.ABCMeta):
13-
@abc.abstractproperty
13+
@property
14+
@abc.abstractmethod
1415
def name(self) -> str:
1516
"""
1617
A string naming this mode (e.g. "AES", "Camellia").
1718
"""
1819

19-
@abc.abstractproperty
20+
@property
21+
@abc.abstractmethod
2022
def key_sizes(self) -> typing.FrozenSet[int]:
2123
"""
2224
Valid key sizes for this algorithm in bits
2325
"""
2426

25-
@abc.abstractproperty
27+
@property
28+
@abc.abstractmethod
2629
def key_size(self) -> int:
2730
"""
2831
The size of the key being used as an integer in bits (e.g. 128, 256).
@@ -32,7 +35,8 @@ def key_size(self) -> int:
3235
class BlockCipherAlgorithm(metaclass=abc.ABCMeta):
3336
key: bytes
3437

35-
@abc.abstractproperty
38+
@property
39+
@abc.abstractmethod
3640
def block_size(self) -> int:
3741
"""
3842
The size of a block as an integer in bits (e.g. 64, 128).

src/cryptography/hazmat/primitives/asymmetric/dh.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ def parameter_numbers(self) -> DHParameterNumbers:
170170

171171

172172
class DHPublicKey(metaclass=abc.ABCMeta):
173-
@abc.abstractproperty
173+
@property
174+
@abc.abstractmethod
174175
def key_size(self) -> int:
175176
"""
176177
The bit length of the prime modulus.
@@ -203,7 +204,8 @@ def public_bytes(
203204

204205

205206
class DHPrivateKey(metaclass=abc.ABCMeta):
206-
@abc.abstractproperty
207+
@property
208+
@abc.abstractmethod
207209
def key_size(self) -> int:
208210
"""
209211
The bit length of the prime modulus.

src/cryptography/hazmat/primitives/hashes.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,22 @@
1010

1111

1212
class HashAlgorithm(metaclass=abc.ABCMeta):
13-
@abc.abstractproperty
13+
@property
14+
@abc.abstractmethod
1415
def name(self) -> str:
1516
"""
1617
A string naming this algorithm (e.g. "sha256", "md5").
1718
"""
1819

19-
@abc.abstractproperty
20+
@property
21+
@abc.abstractmethod
2022
def digest_size(self) -> int:
2123
"""
2224
The size of the resulting digest in bytes.
2325
"""
2426

25-
@abc.abstractproperty
27+
@property
28+
@abc.abstractmethod
2629
def block_size(self) -> typing.Optional[int]:
2730
"""
2831
The internal block size of the hash function, or None if the hash
@@ -31,7 +34,8 @@ def block_size(self) -> typing.Optional[int]:
3134

3235

3336
class HashContext(metaclass=abc.ABCMeta):
34-
@abc.abstractproperty
37+
@property
38+
@abc.abstractmethod
3539
def algorithm(self) -> HashAlgorithm:
3640
"""
3741
A HashAlgorithm that will be used by this context.

0 commit comments

Comments
 (0)