Skip to content

Commit e949b2e

Browse files
authored
Prepare for new ruff release (#9227)
1 parent 7aa4518 commit e949b2e

File tree

9 files changed

+12
-36
lines changed

9 files changed

+12
-36
lines changed

docs/development/custom-vectors/arc4/generate_arc4.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ def _build_vectors():
6969
for offset in _RFC6229_OFFSETS:
7070
if offset % 16 != 0:
7171
raise ValueError(
72-
"Offset {} is not evenly divisible by 16".format(
73-
offset
74-
)
72+
f"Offset {offset} is not evenly divisible by 16"
7573
)
7674
while current_offset < offset:
7775
encryptor.update(plaintext)

docs/development/custom-vectors/cast5/generate_cast5.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ def build_vectors(mode, filename):
3131
if line.startswith("KEY"):
3232
if count != 0:
3333
output.append(
34-
"CIPHERTEXT = {}".format(
35-
encrypt(mode, key, iv, plaintext)
36-
)
34+
f"CIPHERTEXT = {encrypt(mode, key, iv, plaintext)}"
3735
)
3836
output.append(f"\nCOUNT = {count}")
3937
count += 1

src/cryptography/hazmat/backends/openssl/backend.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ def cipher_supported(self, cipher: CipherAlgorithm, mode: Mode) -> bool:
242242
def register_cipher_adapter(self, cipher_cls, mode_cls, adapter) -> None:
243243
if (cipher_cls, mode_cls) in self._cipher_registry:
244244
raise ValueError(
245-
"Duplicate registration for: {} {}.".format(
246-
cipher_cls, mode_cls
247-
)
245+
f"Duplicate registration for: {cipher_cls} {mode_cls}."
248246
)
249247
self._cipher_registry[cipher_cls, mode_cls] = adapter
250248

src/cryptography/hazmat/backends/openssl/rsa.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ def _rsa_sig_setup(
242242
if res <= 0:
243243
backend._consume_errors()
244244
raise UnsupportedAlgorithm(
245-
"{} is not supported for the RSA signature operation.".format(
246-
padding.name
247-
),
245+
f"{padding.name} is not supported for the RSA signature operation",
248246
_Reasons.UNSUPPORTED_PADDING,
249247
)
250248
if isinstance(padding, PSS):

src/cryptography/x509/extensions.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ def public_bytes(self) -> bytes:
104104
Serializes the extension type to DER.
105105
"""
106106
raise NotImplementedError(
107-
"public_bytes is not implemented for extension type {!r}".format(
108-
self
109-
)
107+
f"public_bytes is not implemented for extension type {self!r}"
110108
)
111109

112110

@@ -1795,9 +1793,7 @@ def __init__(self, invalidity_date: datetime.datetime) -> None:
17951793
self._invalidity_date = invalidity_date
17961794

17971795
def __repr__(self) -> str:
1798-
return "<InvalidityDate(invalidity_date={})>".format(
1799-
self._invalidity_date
1800-
)
1796+
return f"<InvalidityDate(invalidity_date={self._invalidity_date})>"
18011797

18021798
def __eq__(self, other: object) -> bool:
18031799
if not isinstance(other, InvalidityDate):
@@ -1841,9 +1837,7 @@ def __init__(
18411837
)
18421838

18431839
def __repr__(self) -> str:
1844-
return "<PrecertificateSignedCertificateTimestamps({})>".format(
1845-
list(self)
1846-
)
1840+
return f"<PrecertificateSignedCertificateTimestamps({list(self)})>"
18471841

18481842
def __hash__(self) -> int:
18491843
return hash(tuple(self._signed_certificate_timestamps))

src/cryptography/x509/general_name.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,7 @@ def value(self) -> bytes:
269269
return self._value
270270

271271
def __repr__(self) -> str:
272-
return "<OtherName(type_id={}, value={!r})>".format(
273-
self.type_id, self.value
274-
)
272+
return f"<OtherName(type_id={self.type_id}, value={self.value!r})>"
275273

276274
def __eq__(self, other: object) -> bool:
277275
if not isinstance(other, OtherName):

tests/hazmat/primitives/test_ec.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ def _skip_ecdsa_vector(backend, curve_type, hash_type):
5555
def _skip_curve_unsupported(backend, curve):
5656
if not backend.elliptic_curve_supported(curve):
5757
pytest.skip(
58-
"Curve {} is not supported by this backend {}".format(
59-
curve.name, backend
60-
)
58+
f"Curve {curve.name} is not supported by this backend {backend}"
6159
)
6260

6361

@@ -66,9 +64,7 @@ def _skip_exchange_algorithm_unsupported(backend, algorithm, curve):
6664
algorithm, curve
6765
):
6866
pytest.skip(
69-
"Exchange with {} curve is not supported by {}".format(
70-
curve.name, backend
71-
)
67+
f"Exchange with {curve.name} curve is not supported by {backend}"
7268
)
7369

7470

tests/hazmat/primitives/test_pkcs12.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
def _skip_curve_unsupported(backend, curve):
4141
if not backend.elliptic_curve_supported(curve):
4242
pytest.skip(
43-
"Curve {} is not supported by this backend {}".format(
44-
curve.name, backend
45-
)
43+
f"Curve {curve.name} is not supported by this backend {backend}"
4644
)
4745

4846

tests/hazmat/primitives/test_x963_vectors.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
def _skip_hashfn_unsupported(backend, hashfn):
2020
if not backend.hash_supported(hashfn):
2121
pytest.skip(
22-
"Hash {} is not supported by this backend {}".format(
23-
hashfn.name, backend
24-
)
22+
f"Hash {hashfn.name} is not supported by this backend {backend}"
2523
)
2624

2725

0 commit comments

Comments
 (0)