Skip to content

List attributes apart from params - #154

Merged
rr- merged 2 commits into
mainfrom
rework/17-attrs
Nov 6, 2026
Merged

rr- merged 2 commits into
mainfrom
rework/17-attrs

Conversation

@rr-

@rr- rr- commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Docstring.params returned attributes along with params. A class docstring with both Args: and Attributes: gave one list, and users had to check kind to tell them apart. Linters such as pydoclint compare documented params against a signature and have to filter attributes out first.

docstring = parse("S.\n\nArgs:\n    x: X.\n\nAttributes:\n    y: Y.", "google")

# before
[p.arg_name for p in docstring.params]  # ['x', 'y']

# after
[p.arg_name for p in docstring.params]  # ['x']
[a.arg_name for a in docstring.attrs]   # ['y']

This is a breaking change for code that read attributes through params. Attributes are still DocstringParam objects with kind=Kind.ATTRIBUTE, so docstring.meta is unchanged. Only the params property filters differently. Attribute docstrings that parse_from_object reads from source show up in attrs too.

Compose works as before, because it writes items by kind. combine_docstrings matches the decorated function's signature against params only. Before, an attribute named like a param could be picked up as that param, or replace the param's description.

Parity against main: 0 of 29,074 docstrings differ (case, stdlib and generated), because parse output itself doesn't change. Bench on 3.8: 0.97–1.01x of main.

Docstring.params included attributes, so code comparing a function's
documented params with its signature saw a class's attributes among
them. params now leaves them out, and the new Docstring.attrs lists
them.
@rr- rr- self-assigned this Nov 6, 2026
@rr-
rr- merged commit da40dd8 into main Nov 6, 2026
24 of 25 checks passed
@rr-
rr- deleted the rework/17-attrs branch November 6, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant