Skip to content

Commit

Permalink
Prepare for new ruff release (#9227)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex authored Jul 13, 2023
1 parent 7aa4518 commit e949b2e
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 36 deletions.
4 changes: 1 addition & 3 deletions docs/development/custom-vectors/arc4/generate_arc4.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ def _build_vectors():
for offset in _RFC6229_OFFSETS:
if offset % 16 != 0:
raise ValueError(
"Offset {} is not evenly divisible by 16".format(
offset
)
f"Offset {offset} is not evenly divisible by 16"
)
while current_offset < offset:
encryptor.update(plaintext)
Expand Down
4 changes: 1 addition & 3 deletions docs/development/custom-vectors/cast5/generate_cast5.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def build_vectors(mode, filename):
if line.startswith("KEY"):
if count != 0:
output.append(
"CIPHERTEXT = {}".format(
encrypt(mode, key, iv, plaintext)
)
f"CIPHERTEXT = {encrypt(mode, key, iv, plaintext)}"
)
output.append(f"\nCOUNT = {count}")
count += 1
Expand Down
4 changes: 1 addition & 3 deletions src/cryptography/hazmat/backends/openssl/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ def cipher_supported(self, cipher: CipherAlgorithm, mode: Mode) -> bool:
def register_cipher_adapter(self, cipher_cls, mode_cls, adapter) -> None:
if (cipher_cls, mode_cls) in self._cipher_registry:
raise ValueError(
"Duplicate registration for: {} {}.".format(
cipher_cls, mode_cls
)
f"Duplicate registration for: {cipher_cls} {mode_cls}."
)
self._cipher_registry[cipher_cls, mode_cls] = adapter

Expand Down
4 changes: 1 addition & 3 deletions src/cryptography/hazmat/backends/openssl/rsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ def _rsa_sig_setup(
if res <= 0:
backend._consume_errors()
raise UnsupportedAlgorithm(
"{} is not supported for the RSA signature operation.".format(
padding.name
),
f"{padding.name} is not supported for the RSA signature operation",
_Reasons.UNSUPPORTED_PADDING,
)
if isinstance(padding, PSS):
Expand Down
12 changes: 3 additions & 9 deletions src/cryptography/x509/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ def public_bytes(self) -> bytes:
Serializes the extension type to DER.
"""
raise NotImplementedError(
"public_bytes is not implemented for extension type {!r}".format(
self
)
f"public_bytes is not implemented for extension type {self!r}"
)


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

def __repr__(self) -> str:
return "<InvalidityDate(invalidity_date={})>".format(
self._invalidity_date
)
return f"<InvalidityDate(invalidity_date={self._invalidity_date})>"

def __eq__(self, other: object) -> bool:
if not isinstance(other, InvalidityDate):
Expand Down Expand Up @@ -1841,9 +1837,7 @@ def __init__(
)

def __repr__(self) -> str:
return "<PrecertificateSignedCertificateTimestamps({})>".format(
list(self)
)
return f"<PrecertificateSignedCertificateTimestamps({list(self)})>"

def __hash__(self) -> int:
return hash(tuple(self._signed_certificate_timestamps))
Expand Down
4 changes: 1 addition & 3 deletions src/cryptography/x509/general_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@ def value(self) -> bytes:
return self._value

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

def __eq__(self, other: object) -> bool:
if not isinstance(other, OtherName):
Expand Down
8 changes: 2 additions & 6 deletions tests/hazmat/primitives/test_ec.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ def _skip_ecdsa_vector(backend, curve_type, hash_type):
def _skip_curve_unsupported(backend, curve):
if not backend.elliptic_curve_supported(curve):
pytest.skip(
"Curve {} is not supported by this backend {}".format(
curve.name, backend
)
f"Curve {curve.name} is not supported by this backend {backend}"
)


Expand All @@ -66,9 +64,7 @@ def _skip_exchange_algorithm_unsupported(backend, algorithm, curve):
algorithm, curve
):
pytest.skip(
"Exchange with {} curve is not supported by {}".format(
curve.name, backend
)
f"Exchange with {curve.name} curve is not supported by {backend}"
)


Expand Down
4 changes: 1 addition & 3 deletions tests/hazmat/primitives/test_pkcs12.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
def _skip_curve_unsupported(backend, curve):
if not backend.elliptic_curve_supported(curve):
pytest.skip(
"Curve {} is not supported by this backend {}".format(
curve.name, backend
)
f"Curve {curve.name} is not supported by this backend {backend}"
)


Expand Down
4 changes: 1 addition & 3 deletions tests/hazmat/primitives/test_x963_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
def _skip_hashfn_unsupported(backend, hashfn):
if not backend.hash_supported(hashfn):
pytest.skip(
"Hash {} is not supported by this backend {}".format(
hashfn.name, backend
)
f"Hash {hashfn.name} is not supported by this backend {backend}"
)


Expand Down

0 comments on commit e949b2e

Please sign in to comment.