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
update some variable names
  • Loading branch information
picnixz committed Dec 2, 2024
commit 658e3322ef707f06d650857edbe55bbffa63df2a
11 changes: 6 additions & 5 deletions Tools/refcounts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
MATCH_TODO = re.compile(r"^#\s*TODO:\s*(\w+)$").match


def generate_object_types(universe: Iterable[str]) -> Iterable[str]:
def generate_object_types(object_types: Iterable[str]) -> Iterable[str]:
"""Generate the type declarations that expect a reference count."""
for qualifier, object_type, suffix in itertools.product(
("const ", ""),
universe,
object_types,
(
"*",
"**", "* *",
Expand All @@ -53,7 +54,7 @@ def generate_object_types(universe: Iterable[str]) -> Iterable[str]:
#: - They are ABI-only (either fully deprecated or even removed).
#: - They are so internal that they should not be used at all because
#: they raise a fatal error.
IGNORE_LIST: frozenset[str] = frozenset((
STABLE_ABI_IGNORE_LIST: frozenset[str] = frozenset((
# part of the stable ABI but should not be used at all
"PyUnicode_GetSize",
# part of the stable ABI but completely removed
Expand All @@ -64,7 +65,7 @@ def generate_object_types(universe: Iterable[str]) -> Iterable[str]:
def flno_(lineno: int) -> str:
# Format the line so that users can C/C from the terminal
# the line number and jump with their editor using Ctrl+G.
return f"{lineno:>5} "
return f"{lineno:>6} "


def is_c_parameter_name(name: str) -> bool:
Expand Down Expand Up @@ -406,7 +407,7 @@ def check_structure(view: FileView, stable_abi_file: str) -> None:
stable_abi = tomllib.loads(stable_abi_str)
expect = stable_abi["function"].keys()
# check if there are missing entries (those marked as "TODO" are ignored)
actual = IGNORE_LIST | view.incomplete | view.signatures.keys()
actual = STABLE_ABI_IGNORE_LIST | view.incomplete | view.signatures.keys()
if missing := (expect - actual):
print(f"Missing {len(missing)} stable ABI entries:")
for name in sorted(missing):
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