]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-118487: Add Black to `.pre-commit-config.yaml` for JIT files (GH-118537)
authorSavannah Ostrowski <savannahostrowski@gmail.com>
Fri, 3 May 2024 17:49:51 +0000 (10:49 -0700)
committerGitHub <noreply@github.com>
Fri, 3 May 2024 17:49:51 +0000 (10:49 -0700)
.pre-commit-config.yaml
Tools/jit/_targets.py

index 663a11897d98e2ed182c0b4e8f4173cb38066f26..fde9d9149bf62b100dc3b8b4d1a85f3af1fcadf9 100644 (file)
@@ -11,6 +11,14 @@ repos:
         args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
         files: ^Tools/clinic/|Lib/test/test_clinic.py
 
+  - repo: https://github.com/psf/black-pre-commit-mirror
+    rev: 24.4.2
+    hooks:
+      - id: black
+        name: Run Black on Tools/jit/
+        files: ^Tools/jit/
+        language_version: python3.12
+
   - repo: https://github.com/pre-commit/pre-commit-hooks
     rev: v4.5.0
     hooks:
index 23bb18947f80ea26dafb73fa85affe8d42f0513e..023ef498a21d7c46781411114364d553a3c784db 100644 (file)
@@ -154,13 +154,20 @@ class _Target(typing.Generic[_S, _R]):
             args_ll = args + [
                 # -fomit-frame-pointer is necessary because the GHC calling
                 # convention uses RBP to pass arguments:
-                "-S", "-emit-llvm", "-fomit-frame-pointer", "-o", f"{ll}", f"{c}"
+                "-S",
+                "-emit-llvm",
+                "-fomit-frame-pointer",
+                "-o",
+                f"{ll}",
+                f"{c}",
             ]
             await _llvm.run("clang", args_ll, echo=self.verbose)
             ir = ll.read_text()
             # This handles declarations, definitions, and calls to named symbols
             # starting with "_JIT_":
-            ir = re.sub(r"(((noalias|nonnull|noundef) )*ptr @_JIT_\w+\()", r"ghccc \1", ir)
+            ir = re.sub(
+                r"(((noalias|nonnull|noundef) )*ptr @_JIT_\w+\()", r"ghccc \1", ir
+            )
             # This handles calls to anonymous callees, since anything with
             # "musttail" needs to use the same calling convention:
             ir = ir.replace("musttail call", "musttail call ghccc")