Skip to content
11 changes: 4 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions Tools/jit/.ruff.toml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion Tools/jit/_llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
AA-Turner marked this conversation as resolved.
Resolved
*args: _P.args,
**kwargs: _P.kwargs, # pylint: disable = no-member
) -> _R:
async with lock:
if args not in cache:
Expand Down
7 changes: 3 additions & 4 deletions Tools/jit/_optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@

@enum.unique
class InstructionKind(enum.Enum):

JUMP = enum.auto()
LONG_BRANCH = enum.auto()
SHORT_BRANCH = enum.auto()
Expand Down Expand Up @@ -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."""
Expand Down
12 changes: 3 additions & 9 deletions Tools/jit/_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<label>[\w."$?@]+)(\s+.*)?')
Expand Down Expand Up @@ -534,9 +530,7 @@ def _handle_relocation(
return _stencils.Hole(offset, kind, value, symbol, addend)


class _MachO(
_Target[_schema.MachOSection, _schema.MachORelocation]
): # pylint: disable = too-few-public-methods
class _MachO(_Target[_schema.MachOSection, _schema.MachORelocation]): # pylint: disable = too-few-public-methods
label_prefix = "L"
symbol_prefix = "_"
re_global = re.compile(r'\s*\.globl\s+(?P<label>[\w."$?@]+)(\s+.*)?')
Expand Down
2 changes: 1 addition & 1 deletion Tools/jit/example_trace_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _run_and_dump(func, n, outdir):

def _main():
if len(sys.argv) < 2 or len(sys.argv) > 3:
print(f"Usage: {sys.argv[0] if sys.argv else " "} OUTDIR [loops]")
print(f"Usage: {sys.argv[0] if sys.argv else ' '} OUTDIR [loops]")
outdir = sys.argv[1]
n = int(sys.argv[2]) if len(sys.argv) > 2 else 5000
functions = [
Expand Down
Loading