Skip to content

Dataclass placeholder attribute causing complaints about fewer attributes being documented. #302

Description

@oliversheridanmethven

If we have:

@dataclasses.dataclass
class Result:
    """
    Class for storing stuff.

    Attributes
    ----------
    foo
        The foo.
    bar
        the bar.
    """
    _: dataclasses.KW_ONLY
    foo: int
    bar: int

The linter complains that the _ placeholder needs documenting:

DOC601 Class `Result`: Class docstring contains fewer class attributes than actual class attributes.  (Please read https://jsh9.github.io/pydoclint/checking_class_attributes.html on how to correctly document class attributes.)
DOC603 Class `Result`: Class docstring attributes are different from actual class attributes. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Attributes in the class definition but not in the docstring: [_: dataclasses.KW_ONLY]. (Please read https://jsh9.github.io/pydoclint/checking_class_attributes.html on how to correctly document class attributes.)

I think perhaps this should be an exception (but no exception made for _baz).

Perhaps some pragma where we could write:

@dataclasses.dataclass
class Result:
    """
    Class for storing stuff.

    Attributes
    ----------
    foo
        The foo.
    bar
        the bar.
    """
    _: dataclasses.KW_ONLY # doclint: ignore[no-docs]
    foo: int
    bar: int

Note that this pragma just says it doesn't need documenting, but does not say anything about type checking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions