Skip to content

Commit 65535ee

Browse files
committed
Use Ruff for all formatting in pre-commit
1 parent 75cbb8d commit 65535ee

File tree

5 files changed

+40
-46
lines changed

5 files changed

+40
-46
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.11.6
3+
rev: v0.11.7
44
hooks:
55
- id: ruff
66
name: Run Ruff (lint) on Doc/
@@ -22,16 +22,13 @@ repos:
2222
name: Run Ruff (format) on Doc/
2323
args: [--check]
2424
files: ^Doc/
25-
26-
- repo: https://github.com/psf/black-pre-commit-mirror
27-
rev: 25.1.0
28-
hooks:
29-
- id: black
30-
name: Run Black on Tools/build/check_warnings.py
25+
- id: ruff-format
26+
name: Run Ruff (format) on Tools/build/check_warnings.py
27+
args: [--check, --config=Tools/build/.ruff.toml]
3128
files: ^Tools/build/check_warnings.py
32-
args: [--line-length=79]
33-
- id: black
34-
name: Run Black on Tools/jit/
29+
- id: ruff-format
30+
name: Run Ruff (format) on Tools/jit/
31+
args: [--check]
3532
files: ^Tools/jit/
3633

3734
- repo: https://github.com/pre-commit/pre-commit-hooks

Tools/build/check_warnings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ def get_unexpected_warnings(
151151
"""
152152
unexpected_warnings = {}
153153
for file in files_with_warnings.keys():
154-
155154
rule = is_file_ignored(file, ignore_rules)
156155

157156
if rule:

Tools/jit/_llvm.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ def _async_cache(f: _C[_P, _R]) -> _C[_P, _R]:
2121
lock = asyncio.Lock()
2222

2323
@functools.wraps(f)
24-
async def wrapper(
25-
*args: _P.args, **kwargs: _P.kwargs # pylint: disable = no-member
26-
) -> _R:
24+
async def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
2725
async with lock:
2826
if args not in cache:
2927
cache[args] = await f(*args, **kwargs)

Tools/jit/_stencils.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -230,35 +230,41 @@ def remove_jump(self) -> None:
230230
"""Remove a zero-length continuation jump, if it exists."""
231231
hole = max(self.holes, key=lambda hole: hole.offset)
232232
match hole:
233-
case Hole(
234-
offset=offset,
235-
kind="IMAGE_REL_AMD64_REL32",
236-
value=HoleValue.GOT,
237-
symbol="_JIT_CONTINUE",
238-
addend=-4,
239-
) as hole:
233+
case (
234+
Hole(
235+
offset=offset,
236+
kind="IMAGE_REL_AMD64_REL32",
237+
value=HoleValue.GOT,
238+
symbol="_JIT_CONTINUE",
239+
addend=-4,
240+
) as hole
241+
):
240242
# jmp qword ptr [rip]
241243
jump = b"\x48\xff\x25\x00\x00\x00\x00"
242244
offset -= 3
243-
case Hole(
244-
offset=offset,
245-
kind="IMAGE_REL_I386_REL32" | "R_X86_64_PLT32" | "X86_64_RELOC_BRANCH",
246-
value=HoleValue.CONTINUE,
247-
symbol=None,
248-
addend=addend,
249-
) as hole if (
250-
_signed(addend) == -4
251-
):
245+
case (
246+
Hole(
247+
offset=offset,
248+
kind="IMAGE_REL_I386_REL32"
249+
| "R_X86_64_PLT32"
250+
| "X86_64_RELOC_BRANCH",
251+
value=HoleValue.CONTINUE,
252+
symbol=None,
253+
addend=addend,
254+
) as hole
255+
) if _signed(addend) == -4:
252256
# jmp 5
253257
jump = b"\xe9\x00\x00\x00\x00"
254258
offset -= 1
255-
case Hole(
256-
offset=offset,
257-
kind="R_AARCH64_JUMP26",
258-
value=HoleValue.CONTINUE,
259-
symbol=None,
260-
addend=0,
261-
) as hole:
259+
case (
260+
Hole(
261+
offset=offset,
262+
kind="R_AARCH64_JUMP26",
263+
value=HoleValue.CONTINUE,
264+
symbol=None,
265+
addend=0,
266+
) as hole
267+
):
262268
# b #4
263269
jump = b"\x00\x00\x00\x14"
264270
case _:

Tools/jit/_targets.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ def build(
224224
jit_stencils_new.unlink(missing_ok=True)
225225

226226

227-
class _COFF(
228-
_Target[_schema.COFFSection, _schema.COFFRelocation]
229-
): # pylint: disable = too-few-public-methods
227+
class _COFF(_Target[_schema.COFFSection, _schema.COFFRelocation]):
230228
def _handle_section(
231229
self, section: _schema.COFFSection, group: _stencils.StencilGroup
232230
) -> None:
@@ -312,9 +310,7 @@ def _handle_relocation(
312310
return _stencils.Hole(offset, kind, value, symbol, addend)
313311

314312

315-
class _ELF(
316-
_Target[_schema.ELFSection, _schema.ELFRelocation]
317-
): # pylint: disable = too-few-public-methods
313+
class _ELF(_Target[_schema.ELFSection, _schema.ELFRelocation]):
318314
def _handle_section(
319315
self, section: _schema.ELFSection, group: _stencils.StencilGroup
320316
) -> None:
@@ -402,9 +398,7 @@ def _handle_relocation(
402398
return _stencils.Hole(offset, kind, value, symbol, addend)
403399

404400

405-
class _MachO(
406-
_Target[_schema.MachOSection, _schema.MachORelocation]
407-
): # pylint: disable = too-few-public-methods
401+
class _MachO(_Target[_schema.MachOSection, _schema.MachORelocation]):
408402
def _handle_section(
409403
self, section: _schema.MachOSection, group: _stencils.StencilGroup
410404
) -> None:

0 commit comments

Comments
 (0)