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
fix some typos
  • Loading branch information
picnixz committed Dec 2, 2024
commit 2eb541f55bd5b184dd3587838fd281c4ae43f50c
15 changes: 11 additions & 4 deletions Tools/refcounts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#: Set of functions part of the stable ABI that are not
#: in the refcounts.dat file if:
#:
#: - They are ABI-only (either fully deprecated or even removed)
#: - 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((
Expand Down Expand Up @@ -105,7 +105,7 @@ class RefEffect(enum.Enum):
NULL = enum.auto() # for return values only
"""Only used for a NULL return value.

This is used by functions that return always return NULL as a "PyObject *".
This is used by functions that always return NULL as a "PyObject *".
"""


Expand Down Expand Up @@ -145,6 +145,7 @@ class LineInfo:
@dataclass(slots=True, frozen=True)
class Return:
"""Indicate a return value."""

ctype: str | None
"""The return C type, if any.

Expand All @@ -166,6 +167,8 @@ class Return:

@dataclass(slots=True, frozen=True)
class Param:
"""Indicate a formal parameter."""

name: str
"""The parameter name."""

Expand All @@ -190,6 +193,8 @@ class Param:

@dataclass(slots=True, frozen=True)
class Signature:
"""An entry in refcounts.dat."""

name: str
"""The function name."""

Expand All @@ -205,6 +210,8 @@ class Signature:

@dataclass(slots=True, frozen=True)
class FileView:
"""View of the refcounts.dat file."""

signatures: Mapping[str, Signature]
"""A mapping from function names to the corresponding signature."""

Expand Down Expand Up @@ -414,7 +421,7 @@ def check_structure(view: FileView, stable_abi_file: str) -> None:
_STABLE_ABI_PATH_SENTINEL: Final = object()


def _create_parser() -> ArgumentParser:
def create_parser() -> ArgumentParser:
parser = ArgumentParser(
prog="lint.py", formatter_class=RawDescriptionHelpFormatter,
description=(
Expand All @@ -432,7 +439,7 @@ def _create_parser() -> ArgumentParser:


def main() -> None:
parser = _create_parser()
parser = create_parser()
args = parser.parse_args()
lines = Path(args.file).read_text(encoding="utf-8").splitlines()
print(" PARSING ".center(80, "-"))
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