Skip to content

Keep class attributes named like params - #162

Merged
rr- merged 1 commit into
mainfrom
rework/26-attrdoc-names
Nov 6, 2026
Merged

rr- merged 1 commit into
mainfrom
rework/26-attrdoc-names

Conversation

@rr-

@rr- rr- commented Nov 6, 2026

Copy link
Copy Markdown
Owner

parse_from_object() dropped a class attribute when the class docstring documented a param of the same name. A common case is a class that documents its __init__ params and stores them as attributes:

class Point:
    """A point.

    :param x: Where it starts.
    """
    x: int = 0
    """Where it is now."""

Before, parse_from_object(Point).attrs was empty. Now it holds x with "Where it is now.", and params still holds the param x. An attribute that the docstring itself documents still takes precedence over the one in the source.

Parity: 0 of 29,123 docstrings differ. That's expected, since the parity tool doesn't run parse_from_object.

parse_from_object skipped a source attribute whose name the docstring
used for anything, params included. A class documenting the __init__
param x lost its attribute x. Skip only names the docstring documents
as attributes, which still win over the source.
@rr- rr- self-assigned this Nov 6, 2026
@rr-
rr- merged commit 1c40c1d into main Nov 6, 2026
25 checks passed
@rr-
rr- deleted the rework/26-attrdoc-names branch November 6, 2026 23:51
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