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 29 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
24 changes: 12 additions & 12 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,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 Expand Up @@ -1435,22 +1435,22 @@ PyModule_CheckExact:int:::
PyModule_CheckExact:PyObject*:p:0:

PyModule_Create:PyObject*::+1:
PyModule_Create:PyModuleDef*:def::
PyModule_Create:PyModuleDef*:def:?:

PyModule_Create2:PyObject*::+1:
PyModule_Create2:PyModuleDef*:def::
PyModule_Create2:PyModuleDef*:def:?:
PyModule_Create2:int:module_api_version::

PyModule_ExecDef:int:::
PyModule_ExecDef:PyObject*:module:0:
PyModule_ExecDef:PyModuleDef*:def::
PyModule_ExecDef:PyModuleDef*:def:?:

PyModule_FromDefAndSpec:PyObject*::+1:
PyModule_FromDefAndSpec:PyModuleDef*:def::
PyModule_FromDefAndSpec:PyModuleDef*:def:?:
PyModule_FromDefAndSpec:PyObject*:spec:0:

PyModule_FromDefAndSpec2:PyObject*::+1:
PyModule_FromDefAndSpec2:PyModuleDef*:def::
PyModule_FromDefAndSpec2:PyModuleDef*:def:?:
PyModule_FromDefAndSpec2:PyObject*:spec:0:
PyModule_FromDefAndSpec2:int:module_api_version::

Expand Down Expand Up @@ -1486,7 +1486,7 @@ PyModule_SetDocString:PyObject*:module:0:
PyModule_SetDocString:const char*:docstring::

PyModuleDef_Init:PyObject*::0:
PyModuleDef_Init:PyModuleDef*:def::
PyModuleDef_Init:PyModuleDef*:def:?:

PyNumber_Absolute:PyObject*::+1:
PyNumber_Absolute:PyObject*:o:0:
Expand Down Expand Up @@ -2152,13 +2152,13 @@ PySlice_Unpack:Py_ssize_t*:step::

PyState_AddModule:int:::
PyState_AddModule:PyObject*:module:+1:
PyState_AddModule:PyModuleDef*:def::
PyState_AddModule:PyModuleDef*:def:?:

PyState_FindModule:PyObject*::0:
PyState_FindModule:PyModuleDef*:def::
PyState_FindModule:PyModuleDef*:def:?:

PyState_RemoveModule:int:::
PyState_RemoveModule:PyModuleDef*:def::
PyState_RemoveModule:PyModuleDef*:def:?:

PyStructSequence_GET_ITEM:PyObject*::0:
PyStructSequence_GET_ITEM:PyObject*:p:0:
Expand Down
43 changes: 43 additions & 0 deletions Tools/refcounts/.ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
target-version = "py312"
line-length = 79
fix = true
preview = true

[lint]
select = [
"I", # isort
"D204", # 1 blank line required after class docstring
"D205", # 1 blank line required between summary line and description
"D400", # First line should end with a period
"D401", # First line of docstring should be in imperative mood
"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
"PGH003", # Use specific rule codes when ignoring type issues
"PGH004", # Use specific rule codes when using noqa
"C4", # flake8-comprehensions
"ISC", # flake8-implicit-str-concat
"TCH", # flake8-type-checking
"PTH", # flake8-use-pathlib
"PERF101", # unnecessary-list-cast
"PERF102", # incorrect-dict-iterator
"PERF401", # manual-list-comprehension
"PERF402", # manual-list-copy
"PERF403", # manual-dict-comprehension
"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