]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-110558: Run ruff on Argument Clinic in CI (#110559) (#110598)
authorAlex Waygood <Alex.Waygood@Gmail.com>
Tue, 10 Oct 2023 08:58:56 +0000 (10:58 +0200)
committerGitHub <noreply@github.com>
Tue, 10 Oct 2023 08:58:56 +0000 (08:58 +0000)
.github/workflows/lint.yml
.pre-commit-config.yaml
Lib/test/.ruff.toml
Lib/test/test_clinic.py
Tools/clinic/.ruff.toml [new file with mode: 0644]

index 89f65816b6969d056694d3b91e3b11f0d0fdfba6..6c1c29a58cf4fc87bf7e12b8d1f660913213ee4c 100644 (file)
@@ -7,7 +7,7 @@ permissions:
 
 env:
   FORCE_COLOR: 1
-  RUFF_FORMAT: github
+  RUFF_OUTPUT_FORMAT: github
 
 concurrency:
   group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
index 82863ad326f04d60d1f6a68a452c480ce25071e1..ffca103bb33e8602e7302e664993da52b72561c0 100644 (file)
@@ -6,6 +6,10 @@ repos:
         name: Run Ruff on Lib/test/
         args: [--exit-non-zero-on-fix]
         files: ^Lib/test/
+      - id: ruff
+        name: Run Ruff on Tools/clinic/
+        args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
+        files: ^Tools/clinic/|Lib/test/test_clinic.py
 
   - repo: https://github.com/pre-commit/pre-commit-hooks
     rev: v4.4.0
index 99521dd0ec657420af0228842513c5db17602c0a..52a84f6a3794276e6cc5eb89f05f3075ba3ea8e2 100644 (file)
@@ -3,6 +3,8 @@ select = [
     "F811",  # Redefinition of unused variable (useful for finding test methods with the same name)
 ]
 extend-exclude = [
+    # Excluded (run with the other AC files in its own separate ruff job in pre-commit)
+    "test_clinic.py",
     # Failed to lint
     "badsyntax_pep3120.py",
     "encoded_modules/module_iso_8859_1.py",
index 520cc51302212d8d5180181bbf6958e2e916aab6..23487958f456486b646171d9d08d622d4c288fc1 100644 (file)
@@ -4,7 +4,6 @@
 
 from test import support, test_tools
 from test.support import os_helper
-from test.support import SHORT_TIMEOUT, requires_subprocess
 from test.support.os_helper import TESTFN, unlink
 from textwrap import dedent
 from unittest import TestCase
@@ -600,7 +599,6 @@ class ClinicParserTest(_ParserBase):
                 follow_symlinks: bool = True
                 something_else: str = ''
         """)
-        p = function.parameters['follow_symlinks']
         self.assertEqual(3, len(function.parameters))
         conv = function.parameters['something_else'].converter
         self.assertIsInstance(conv, clinic.str_converter)
diff --git a/Tools/clinic/.ruff.toml b/Tools/clinic/.ruff.toml
new file mode 100644 (file)
index 0000000..3bc9d90
--- /dev/null
@@ -0,0 +1,14 @@
+target-version = "py310"
+fix = true
+select = [
+    "F",  # Enable all pyflakes rules
+    "RUF100",  # Ban unused `# noqa` comments
+    "PGH004",  # Ban blanket `# noqa` comments (only ignore specific error codes)
+]
+unfixable = [
+    # The autofixes sometimes do the wrong things for these;
+    # it's better to have to manually look at the code and see how it needs fixing
+    "F841",  # Detects unused variables
+    "F601",  # Detects dictionaries that have duplicate keys
+    "F602",  # Also detects dictionaries that have duplicate keys
+]