mirror of https://github.com/python/cpython
gh-110558: Run ruff on Argument Clinic in CI (#110559)
This commit is contained in:
parent
96fed66a65
commit
7b2764e798
|
@ -7,7 +7,7 @@ permissions:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
FORCE_COLOR: 1
|
FORCE_COLOR: 1
|
||||||
RUFF_FORMAT: github
|
RUFF_OUTPUT_FORMAT: github
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||||
|
|
|
@ -6,6 +6,10 @@ repos:
|
||||||
name: Run Ruff on Lib/test/
|
name: Run Ruff on Lib/test/
|
||||||
args: [--exit-non-zero-on-fix]
|
args: [--exit-non-zero-on-fix]
|
||||||
files: ^Lib/test/
|
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
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.4.0
|
rev: v4.4.0
|
||||||
|
|
|
@ -3,6 +3,8 @@ select = [
|
||||||
"F811", # Redefinition of unused variable (useful for finding test methods with the same name)
|
"F811", # Redefinition of unused variable (useful for finding test methods with the same name)
|
||||||
]
|
]
|
||||||
extend-exclude = [
|
extend-exclude = [
|
||||||
|
# Excluded (run with the other AC files in its own separate ruff job in pre-commit)
|
||||||
|
"test_clinic.py",
|
||||||
# Excluded (these aren't actually executed, they're just "data files")
|
# Excluded (these aren't actually executed, they're just "data files")
|
||||||
"tokenizedata/*.py",
|
"tokenizedata/*.py",
|
||||||
# Failed to lint
|
# Failed to lint
|
||||||
|
|
|
@ -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
|
||||||
|
]
|
|
@ -924,7 +924,6 @@ class CLanguage(Language):
|
||||||
|
|
||||||
# Format the preprocessor warning and error messages.
|
# Format the preprocessor warning and error messages.
|
||||||
assert isinstance(self.cpp.filename, str)
|
assert isinstance(self.cpp.filename, str)
|
||||||
source = os.path.basename(self.cpp.filename)
|
|
||||||
message = f"Update the clinic input of {func.full_name!r}."
|
message = f"Update the clinic input of {func.full_name!r}."
|
||||||
code = self.COMPILER_DEPRECATION_WARNING_PROTOTYPE.format(
|
code = self.COMPILER_DEPRECATION_WARNING_PROTOTYPE.format(
|
||||||
major=minversion[0],
|
major=minversion[0],
|
||||||
|
@ -1846,7 +1845,6 @@ class CLanguage(Language):
|
||||||
last_group = 0
|
last_group = 0
|
||||||
first_optional = len(selfless)
|
first_optional = len(selfless)
|
||||||
positional = selfless and selfless[-1].is_positional_only()
|
positional = selfless and selfless[-1].is_positional_only()
|
||||||
new_or_init = f.kind.new_or_init
|
|
||||||
has_option_groups = False
|
has_option_groups = False
|
||||||
|
|
||||||
# offset i by -1 because first_optional needs to ignore self
|
# offset i by -1 because first_optional needs to ignore self
|
||||||
|
@ -6343,7 +6341,6 @@ class DSLParser:
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
no_param_after_symbol = True
|
|
||||||
for p in reversed(self.function.parameters.values()):
|
for p in reversed(self.function.parameters.values()):
|
||||||
if self.keyword_only:
|
if self.keyword_only:
|
||||||
if p.kind == inspect.Parameter.KEYWORD_ONLY:
|
if p.kind == inspect.Parameter.KEYWORD_ONLY:
|
||||||
|
|
Loading…
Reference in New Issue