From d706e6499863939d22b1923ac38e82c6e20c0439 Mon Sep 17 00:00:00 2001 From: Pierre Le Marre Date: Fri, 10 Jan 2025 14:18:21 +0100 Subject: [PATCH] scripts: Fix formatting with Ruff 0.9 See: https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md#090 --- .pre-commit-config.yaml | 2 +- scripts/perfect_hash.py | 5 ++--- scripts/update-message-registry.py | 6 +++--- scripts/update-unicode.py | 6 +++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 71af43f5c..31c456cb3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: - id: check-yaml - id: check-added-large-files - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.5.1 + rev: v0.9.0 hooks: - id: ruff # ambiguous-variable-name (E741), line-too-long (E501) diff --git a/scripts/perfect_hash.py b/scripts/perfect_hash.py index a043b83b7..e49b97d46 100644 --- a/scripts/perfect_hash.py +++ b/scripts/perfect_hash.py @@ -554,8 +554,7 @@ def main() -> None: action="store", default=76, type="int", - help="Maximal width of generated list when " - "wrapped. Default width is %default", + help="Maximal width of generated list when wrapped. Default width is %default", metavar="INT", ) @@ -622,7 +621,7 @@ def main() -> None: "-e", "--execute", action="store_true", - help="Execute the generated code within " "the Python interpreter.", + help="Execute the generated code within the Python interpreter.", ) parser.add_option( diff --git a/scripts/update-message-registry.py b/scripts/update-message-registry.py index 626a706b2..5637e870e 100755 --- a/scripts/update-message-registry.py +++ b/scripts/update-message-registry.py @@ -31,9 +31,9 @@ def parse(cls, raw_version: str) -> Version: if raw_version == cls.UNKNOWN_VERSION: raw_version = cls.DEFAULT_VERSION version = raw_version.split(".") - assert 2 <= len(version) <= 3 and all( - n.isdecimal() for n in version - ), raw_version + assert 2 <= len(version) <= 3 and all(n.isdecimal() for n in version), ( + raw_version + ) return Version(*map(int, version)) diff --git a/scripts/update-unicode.py b/scripts/update-unicode.py index fbbe2668f..3ddf3204f 100755 --- a/scripts/update-unicode.py +++ b/scripts/update-unicode.py @@ -1659,7 +1659,7 @@ def optimize( f"data_overlap={s.data_overlap}", f"offsets1={len(s.offsets1)} (uint size: {s.offsets1_int_size})", f"offsets2={len(s.offsets2)} (uint size: {s.offsets2_int_size})", - f"total={s.total} ({s.total//8})", + f"total={s.total} ({s.total // 8})", ) print(f"Total: {result.total} ({result.total // 8})") print("".center(90, "*")) @@ -1827,7 +1827,7 @@ def generate(cls, root: Path, write: bool, config: Config) -> None: @staticmethod def myHex(n: int, max_hex_length: int) -> str: return ( - f"""{"-" if n < 0 else " "}0x{hex(abs(n))[2:].rjust(max_hex_length, '0')}""" + f"""{"-" if n < 0 else " "}0x{hex(abs(n))[2:].rjust(max_hex_length, "0")}""" ) @classmethod @@ -1959,7 +1959,7 @@ def run( assert best_solution for strategy, sol in zip(strategies, results): print( - f"{strategy.name}: {sol.total} ({sol.total//8})", + f"{strategy.name}: {sol.total} ({sol.total // 8})", "✨✨✨" if sol is best_solution else "", ) best_solution.test(config)