]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-60283: Check for redefined test names in CI (#109161)
authorHugo van Kemenade <hugovk@users.noreply.github.com>
Tue, 12 Sep 2023 15:28:20 +0000 (09:28 -0600)
committerGitHub <noreply@github.com>
Tue, 12 Sep 2023 15:28:20 +0000 (15:28 +0000)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
.github/CODEOWNERS
.github/workflows/build.yml
.github/workflows/lint.yml
.pre-commit-config.yaml
Lib/test/.ruff.toml [new file with mode: 0644]

index 81c580eb77862599bb2a43ce6d3d628762ad2ba6..cd35cba5b5c56da6caa1a3c2f69d88903e9a0c29 100644 (file)
@@ -9,6 +9,7 @@
 
 # pre-commit
 .pre-commit-config.yaml       @hugovk @AlexWaygood
+.ruff.toml                    @hugovk @AlexWaygood
 
 # Build system
 configure*                    @erlend-aasland @corona10
index 668ae499f06f17f436cc820aa974e7b64601af37..cbe5c841a433cf0bd9320a7cf0e256f624896652 100644 (file)
@@ -63,7 +63,7 @@ jobs:
             # into the PR branch anyway.
             #
             # https://github.com/python/core-workflow/issues/373
-            git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc)' && echo "run_tests=true" >> $GITHUB_OUTPUT || true
+            git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc|^\.pre-commit-config\.yaml$|\.ruff\.toml$)' && echo "run_tests=true" >> $GITHUB_OUTPUT || true
           fi
 
           # Check if we should run hypothesis tests
index 27b04ba1d412e3ef9c9393d3c41a2f4bd1093a18..89f65816b6969d056694d3b91e3b11f0d0fdfba6 100644 (file)
@@ -5,6 +5,10 @@ on: [push, pull_request, workflow_dispatch]
 permissions:
   contents: read
 
+env:
+  FORCE_COLOR: 1
+  RUFF_FORMAT: github
+
 concurrency:
   group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
   cancel-in-progress: true
index 68e75fa44fab60b644b19413188e5c5b429f13e9..4c1fd20ea921b86a7927a68d1f4eef29183cd686 100644 (file)
@@ -1,7 +1,17 @@
 repos:
+  - repo: https://github.com/astral-sh/ruff-pre-commit
+    rev: v0.0.288
+    hooks:
+      - id: ruff
+        name: Run Ruff on Lib/test/
+        args: [--exit-non-zero-on-fix]
+        files: ^Lib/test/
+
   - repo: https://github.com/pre-commit/pre-commit-hooks
     rev: v4.4.0
     hooks:
+      - id: check-toml
+        exclude: ^Lib/test/test_tomllib/
       - id: check-yaml
       - id: end-of-file-fixer
         types: [python]
diff --git a/Lib/test/.ruff.toml b/Lib/test/.ruff.toml
new file mode 100644 (file)
index 0000000..a9a4a01
--- /dev/null
@@ -0,0 +1,35 @@
+fix = true
+select = [
+    "F811",  # Redefinition of unused variable (useful for finding test methods with the same name)
+]
+extend-exclude = [
+    # Failed to lint
+    "badsyntax_pep3120.py",
+    "encoded_modules/module_iso_8859_1.py",
+    "encoded_modules/module_koi8_r.py",
+    # Failed to parse
+    "badsyntax_3131.py",
+    "support/socket_helper.py",
+    "test_fstring.py",
+    # TODO Fix: F811 Redefinition of unused name
+    "test__opcode.py",
+    "test_buffer.py",
+    "test_ctypes/test_arrays.py",
+    "test_ctypes/test_functions.py",
+    "test_dataclasses/__init__.py",
+    "test_descr.py",
+    "test_enum.py",
+    "test_functools.py",
+    "test_genericclass.py",
+    "test_grammar.py",
+    "test_import/__init__.py",
+    "test_keywordonlyarg.py",
+    "test_pkg.py",
+    "test_subclassinit.py",
+    "test_typing.py",
+    "test_unittest/testmock/testpatch.py",
+    "test_yield_from.py",
+    "time_hashlib.py",
+    # Pending https://github.com/python/cpython/pull/109139
+    "test_monitoring.py",
+]