Skip to content

Commit 3688672

Browse files
authored
[3.12] gh-110558: Run ruff on Argument Clinic in CI (#110559) (#110598)
1 parent 0ffbde4 commit 3688672

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ permissions:
77

88
env:
99
FORCE_COLOR: 1
10-
RUFF_FORMAT: github
10+
RUFF_OUTPUT_FORMAT: github
1111

1212
concurrency:
1313
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.pre-commit-config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ repos:
66
name: Run Ruff on Lib/test/
77
args: [--exit-non-zero-on-fix]
88
files: ^Lib/test/
9+
- id: ruff
10+
name: Run Ruff on Tools/clinic/
11+
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
12+
files: ^Tools/clinic/|Lib/test/test_clinic.py
913

1014
- repo: https://github.com/pre-commit/pre-commit-hooks
1115
rev: v4.4.0

Lib/test/.ruff.toml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ select = [
33
"F811", # Redefinition of unused variable (useful for finding test methods with the same name)
44
]
55
extend-exclude = [
6+
# Excluded (run with the other AC files in its own separate ruff job in pre-commit)
7+
"test_clinic.py",
68
# Failed to lint
79
"badsyntax_pep3120.py",
810
"encoded_modules/module_iso_8859_1.py",

Lib/test/test_clinic.py

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from test import support, test_tools
66
from test.support import os_helper
7-
from test.support import SHORT_TIMEOUT, requires_subprocess
87
from test.support.os_helper import TESTFN, unlink
98
from textwrap import dedent
109
from unittest import TestCase
@@ -600,7 +599,6 @@ def test_param_no_docstring(self):
600599
follow_symlinks: bool = True
601600
something_else: str = ''
602601
""")
603-
p = function.parameters['follow_symlinks']
604602
self.assertEqual(3, len(function.parameters))
605603
conv = function.parameters['something_else'].converter
606604
self.assertIsInstance(conv, clinic.str_converter)

Tools/clinic/.ruff.toml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
target-version = "py310"
2+
fix = true
3+
select = [
4+
"F", # Enable all pyflakes rules
5+
"RUF100", # Ban unused `# noqa` comments
6+
"PGH004", # Ban blanket `# noqa` comments (only ignore specific error codes)
7+
]
8+
unfixable = [
9+
# The autofixes sometimes do the wrong things for these;
10+
# it's better to have to manually look at the code and see how it needs fixing
11+
"F841", # Detects unused variables
12+
"F601", # Detects dictionaries that have duplicate keys
13+
"F602", # Also detects dictionaries that have duplicate keys
14+
]

0 commit comments

Comments
 (0)