diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6878a7d92e3bee..1c74e9a4632872 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -54,18 +54,15 @@ repos: name: Run Ruff (format) on Tools/build/check_warnings.py args: [--exit-non-zero-on-fix, --config=Tools/build/.ruff.toml] files: ^Tools/build/check_warnings.py + - id: ruff-format + name: Run Ruff (format) on Tools/jit/ + args: [--config=Tools/jit/.ruff.toml] + files: ^Tools/jit/ - id: ruff-format name: Run Ruff (format) on Tools/wasm/ args: [--exit-non-zero-on-fix, --config=Tools/wasm/.ruff.toml] files: ^Tools/wasm/ - - repo: https://github.com/psf/black-pre-commit-mirror - rev: ea488cebbfd88a5f50b8bd95d5c829d0bb76feb8 # frozen: 26.1.0 - hooks: - - id: black - name: Run Black on Tools/jit/ - files: ^Tools/jit/ - - repo: https://github.com/Lucas-C/pre-commit-hooks rev: ad1b27d73581aa16cca06fc4a0761fc563ffe8e8 # frozen: v1.5.6 hooks: diff --git a/Tools/jit/.ruff.toml b/Tools/jit/.ruff.toml new file mode 100644 index 00000000000000..6c4b0e77664384 --- /dev/null +++ b/Tools/jit/.ruff.toml @@ -0,0 +1,7 @@ +extend = "../../.ruff.toml" # Inherit the project-wide settings + +line-length = 88 # slightly longer than PEP 8, for readability + +[format] +preview = true +docstring-code-format = true diff --git a/Tools/jit/_llvm.py b/Tools/jit/_llvm.py index 601752bf1f6396..48bf171f269cd7 100644 --- a/Tools/jit/_llvm.py +++ b/Tools/jit/_llvm.py @@ -24,7 +24,8 @@ def _async_cache(f: _C[_P, _R]) -> _C[_P, _R]: @functools.wraps(f) async def wrapper( - *args: _P.args, **kwargs: _P.kwargs # pylint: disable = no-member + *args: _P.args, + **kwargs: _P.kwargs, # pylint: disable = no-member ) -> _R: async with lock: if args not in cache: diff --git a/Tools/jit/_optimizers.py b/Tools/jit/_optimizers.py index f192783a55950c..e52497103727cc 100644 --- a/Tools/jit/_optimizers.py +++ b/Tools/jit/_optimizers.py @@ -91,7 +91,6 @@ @enum.unique class InstructionKind(enum.Enum): - JUMP = enum.auto() LONG_BRANCH = enum.auto() SHORT_BRANCH = enum.auto() @@ -534,9 +533,9 @@ def _validate(self) -> None: continue for inst in block.instructions: if self.frame_pointers: - assert ( - self._frame_pointer_modify.match(inst.text) is None - ), "Frame pointer should not be modified" + assert self._frame_pointer_modify.match(inst.text) is None, ( + "Frame pointer should not be modified" + ) def run(self) -> None: """Run this optimizer.""" diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py index 15cac3de3fe11f..a5c7e77497d849 100644 --- a/Tools/jit/_targets.py +++ b/Tools/jit/_targets.py @@ -328,9 +328,7 @@ def build( jit_stencils_new.unlink(missing_ok=True) -class _COFF( - _Target[_schema.COFFSection, _schema.COFFRelocation] -): # pylint: disable = too-few-public-methods +class _COFF(_Target[_schema.COFFSection, _schema.COFFRelocation]): # pylint: disable = too-few-public-methods def _shim_compile_args(self) -> list[str]: # The linked shim is part of pythoncore, not a shared extension. # On Windows, Py_BUILD_CORE_MODULE makes public APIs import from @@ -443,9 +441,7 @@ def _compile_args(self) -> list[str]: return [runtime, *self.args] -class _ELF( - _Target[_schema.ELFSection, _schema.ELFRelocation] -): # pylint: disable = too-few-public-methods +class _ELF(_Target[_schema.ELFSection, _schema.ELFRelocation]): # pylint: disable = too-few-public-methods label_prefix = ".L" symbol_prefix = "" re_global = re.compile(r'\s*\.globl\s+(?P