Skip to content

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

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

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add lineno to RETURN values and use kw-only
  • Loading branch information
picnixz committed Dec 2, 2024
commit 45584830a048e49abe1f719c5be7ea981f401b3a
15 changes: 9 additions & 6 deletions Tools/refcounts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,26 @@ class Return:
ctype: str | None
reftype: RefType | None
comment: str
lineno: int = field(kw_only=True)


@dataclass(slots=True, frozen=True)
class Param:
name: str
lineno: int

ctype: str | None
reftype: RefType | None
comment: str

lineno: int = field(kw_only=True)


@dataclass(slots=True, frozen=True)
class Signature:
name: str
lineno: int
rparam: Return
params: dict[str, Param] = field(default_factory=dict)
lineno: int = field(kw_only=True)


@dataclass(slots=True, frozen=True)
Expand Down Expand Up @@ -221,18 +223,19 @@ def parse(lines: Iterable[str]) -> FileView:
# process return value
if name is not None:
w.warn(lineno, f"named return value in {line!r}")
ret_param = Return(ctype, reftype, comment)
signatures[func] = Signature(func, lineno, ret_param)
ret_param = Return(ctype, reftype, comment, lineno=lineno)
signatures[func] = Signature(func, ret_param, lineno=lineno)
else:
# process parameter
if name is None:
w.error(lineno, f"missing parameter name in {line!r}")
continue
sig: Signature = signatures[func]
if name in sig.params:
params = sig.params
if name in params:
w.error(lineno, f"duplicated parameter name in {line!r}")
continue
sig.params[name] = Param(name, lineno, ctype, reftype, comment)
params[name] = Param(name, ctype, reftype, comment, lineno=lineno)

if w.count:
print()
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy