Skip to content

[3.12] gh-60283: Check for redefined test names in CI (GH-109161) #109365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# pre-commit
.pre-commit-config.yaml @hugovk @AlexWaygood
.ruff.toml @hugovk @AlexWaygood

# Build system
configure* @erlend-aasland @corona10
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
42 changes: 42 additions & 0 deletions Lib/test/.ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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",
"test_lib2to3/data/bom.py",
"test_lib2to3/data/crlf.py",
"test_lib2to3/data/different_encoding.py",
"test_lib2to3/data/false_encoding.py",
"test_lib2to3/data/py2_test_grammar.py",
# TODO Fix: F811 Redefinition of unused name
"test_buffer.py",
"test_capi/test_misc.py",
"test_capi/test_unicode.py",
"test_ctypes/test_arrays.py",
"test_ctypes/test_functions.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_lib2to3/data/py3_test_grammar.py",
"test_pkg.py",
"test_subclassinit.py",
"test_tokenize.py",
"test_typing.py",
"test_yield_from.py",
"time_hashlib.py",
# Pending https://github.com/python/cpython/pull/109139
"test_monitoring.py",
]