]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-60283: Check for redefined test names in CI (#109161) (#109366)
authorHugo van Kemenade <hugovk@users.noreply.github.com>
Fri, 15 Sep 2023 05:45:23 +0000 (23:45 -0600)
committerGitHub <noreply@github.com>
Fri, 15 Sep 2023 05:45:23 +0000 (05:45 +0000)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
(cherry picked from commit 3cb9a8edca6e3fa0f0045b03a9a6444cf8f7affe)

.github/CODEOWNERS
.github/workflows/build.yml
.github/workflows/lint.yml
.pre-commit-config.yaml
Lib/test/.ruff.toml [new file with mode: 0644]

index 99d701daa1d49abeade3c6938f1b410ba901c9f2..1b156c829cd9aad2ab1d6ac997a5a36daa500811 100644 (file)
@@ -9,6 +9,7 @@
 
 # pre-commit
 .pre-commit-config.yaml       @hugovk @AlexWaygood
+.ruff.toml                    @hugovk @AlexWaygood
 
 # asyncio
 **/*asyncio*                  @1st1 @asvetlov
index 30d2a973a31d3d755e607713719caad2a51bee75..4baa65cf948d2dff597fd667a0e6cf4329bb7757 100644 (file)
@@ -62,7 +62,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
             git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qE '(ssl|hashlib|hmac|^.github)' && echo "run_ssl_tests=true" >> $GITHUB_OUTPUT || true
           fi
       - name: Compute hash for config cache key
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 889bd8502a10eab1c5f1613258b58d51e4f41dfc..980b616559ff32d8c7e9d0ca7e58131e44a30e8b 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: trailing-whitespace
         types_or: [c, python, rst]
diff --git a/Lib/test/.ruff.toml b/Lib/test/.ruff.toml
new file mode 100644 (file)
index 0000000..24f3f8c
--- /dev/null
@@ -0,0 +1,30 @@
+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",
+    "test_source_encoding.py",
+    # Failed to parse
+    "badsyntax_3131.py",
+    "test_fstring.py",
+    # TODO Fix: F811 Redefinition of unused name
+    "test_buffer.py",
+    "test_dataclasses.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_tokenize.py",
+    "test_typing.py",
+    "test_yield_from.py",
+    "time_hashlib.py",
+]