Skip to content
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

gh-127443: add tool for linting Doc/data/refcounts.dat #127476

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
183388f
Add tool for linting `Doc/data/refcounts.dat`
picnixz Dec 1, 2024
9c2a109
use single-quotes
picnixz Dec 1, 2024
6c1a19e
add default paths
picnixz Dec 1, 2024
419197b
use NamedTuple whenever possible
picnixz Dec 1, 2024
58ffbeb
address Peter's review
picnixz Dec 1, 2024
9a46f10
fix typos
picnixz Dec 1, 2024
8372de6
address Alex's review
picnixz Dec 2, 2024
4bcf719
format using a mix of black/ruff/picnixz format
picnixz Dec 2, 2024
841a4b1
rename STEALS -> STEAL
picnixz Dec 2, 2024
970cbc7
detect more ref. count manageable objects
picnixz Dec 2, 2024
4558483
add `lineno` to RETURN values and use kw-only
picnixz Dec 2, 2024
b8f6090
use helper for C identifier detection
picnixz Dec 2, 2024
db9b6e6
`RefType` -> `RefEffect`
picnixz Dec 2, 2024
480f500
improve `ParserReporter`
picnixz Dec 2, 2024
9814dd7
disallow stolen ref in return values
picnixz Dec 2, 2024
82766b3
add doc
picnixz Dec 2, 2024
e7a7a10
fix workflow
picnixz Dec 2, 2024
f64a23d
update pre-commit hook
picnixz Dec 2, 2024
2eb541f
fix some typos
picnixz Dec 2, 2024
cf42e03
restrict the ruff rules
picnixz Dec 2, 2024
eb893d0
add ruff docstrings rules
picnixz Dec 2, 2024
dbe29a6
address Peter's review
picnixz Dec 2, 2024
658e332
update some variable names
picnixz Dec 2, 2024
5660ffe
add TODO messages
picnixz Dec 2, 2024
afceff0
RefEffect -> Effect
picnixz Dec 2, 2024
d173d7a
extract checking logic into smaller functions
picnixz Dec 2, 2024
0edd489
add --strict errors mode
picnixz Dec 2, 2024
a3becf0
additional stealing effects
picnixz Dec 2, 2024
3ac1ff1
Merge remote-tracking branch 'upstream/main' into tools/refcounts/lin…
picnixz Dec 2, 2024
baf2474
address Hugo's review
picnixz Dec 2, 2024
549ba49
remove TODO symbols for now (we don't want yet to change the Sphinx e…
picnixz Dec 2, 2024
c708a4c
address Alex's review
picnixz Dec 2, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
- "Tools/jit/**"
- "Tools/peg_generator/**"
- "Tools/requirements-dev.txt"
- "Tools/refcounts/lint.py"
picnixz marked this conversation as resolved.
Show resolved Hide resolved
- "Tools/wasm/**"
workflow_dispatch:

Expand Down Expand Up @@ -43,6 +44,7 @@ jobs:
"Tools/cases_generator",
"Tools/clinic",
"Tools/jit",
"Tools/refcounts",
"Tools/peg_generator",
"Tools/wasm",
]
Expand Down
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ repos:
name: Run Ruff (lint) on Argument Clinic
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
files: ^Tools/clinic/|Lib/test/test_clinic.py
- id: ruff
name: Run Ruff (lint) on Tools/refcounts/lint.py
args: [--exit-non-zero-on-fix, --config=Tools/refcounts/.ruff.toml]
files: ^Tools/refcounts/lint.py
- id: ruff-format
name: Run Ruff (format) on Doc/
args: [--check]
Expand Down
6 changes: 3 additions & 3 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,11 @@ PyEval_EvalCodeEx:PyObject*::+1:
PyEval_EvalCodeEx:PyObject*:co:0:
PyEval_EvalCodeEx:PyObject*:globals:0:
PyEval_EvalCodeEx:PyObject*:locals:0:
PyEval_EvalCodeEx:PyObject*const*:args::
PyEval_EvalCodeEx:PyObject*const*:args:0:
PyEval_EvalCodeEx:int:argcount::
PyEval_EvalCodeEx:PyObject*const*:kws::
PyEval_EvalCodeEx:PyObject*const*:kws:0:
PyEval_EvalCodeEx:int:kwcount::
PyEval_EvalCodeEx:PyObject*const*:defs::
PyEval_EvalCodeEx:PyObject*const*:defs:0:
PyEval_EvalCodeEx:int:defcount::
PyEval_EvalCodeEx:PyObject*:kwdefs:0:
PyEval_EvalCodeEx:PyObject*:closure:0:
Expand Down
33 changes: 33 additions & 0 deletions Tools/refcounts/.ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
target-version = "py312"
line-length = 79
fix = true
preview = true

[lint]
select = [
"I", # isort
"F", # Enable all pyflakes rules
"E", # Enable all pycodestyle error rules
"W", # Enable all pycodestyle warning rules
"UP", # Enable all pyupgrade rules
"RUF100", # Ban unused `# noqa` comments
"C4", # flake8-comprehensions
"ISC", # flake8-implicit-str-concat
"TCH", # flake8-type-checking
"PTH", # flake8-use-pathlib
"PERF", # perflint
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved
"FURB101", # read-whole-file
"FURB103", # write-whole-file
"FURB110", # if-exp-instead-of-operator
"FURB113", # repeated-append
"FURB116", # f-string-number-format
"FURB129", # readlines-in-for
"FURB132", # check-and-remove-from-set
"FURB136", # if-expr-min-max
"FURB142", # for-loop-set-mutations
"FURB167", # regex-flag-alias
"FURB177", # implicit-cwd
]

[lint.pycodestyle]
max-doc-length = 79
Loading
Loading