Reformat everything with black.

I had to undo the u string prefix removals to not drop Python 2 compatibility.
That's why black isn't enabled in antsibull-nox.toml yet.
This commit is contained in:
Felix Fontein
2025-04-28 09:51:33 +02:00
parent 04a0d38e3b
commit aec1826c34
118 changed files with 11780 additions and 7565 deletions

View File

@@ -21,12 +21,12 @@ def th(number):
mod_100 = abs_number % 100
if mod_100 not in (11, 12, 13):
if mod_10 == 1:
return 'st'
return "st"
if mod_10 == 2:
return 'nd'
return "nd"
if mod_10 == 3:
return 'rd'
return 'th'
return "rd"
return "th"
def parse_serial(value):
@@ -35,14 +35,17 @@ def parse_serial(value):
"""
value = to_native(value)
result = 0
for i, part in enumerate(value.split(':')):
for i, part in enumerate(value.split(":")):
try:
part_value = int(part, 16)
if part_value < 0 or part_value > 255:
raise ValueError('the value is not in range [0, 255]')
raise ValueError("the value is not in range [0, 255]")
except ValueError as exc:
raise ValueError("The {idx}{th} part {part!r} is not a hexadecimal number in range [0, 255]: {exc}".format(
idx=i + 1, th=th(i + 1), part=part, exc=exc))
raise ValueError(
"The {idx}{th} part {part!r} is not a hexadecimal number in range [0, 255]: {exc}".format(
idx=i + 1, th=th(i + 1), part=part, exc=exc
)
)
result = (result << 8) | part_value
return result
@@ -53,5 +56,5 @@ def to_serial(value):
"""
value = convert_int_to_hex(value).upper()
if len(value) % 2 != 0:
value = '0' + value
return ':'.join(value[i:i + 2] for i in range(0, len(value), 2))
value = "0" + value
return ":".join(value[i : i + 2] for i in range(0, len(value), 2))