Skip to content
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

Feature request: Add support for dataclasses #604

Open
Dementiy opened this issue Feb 3, 2025 · 2 comments
Open

Feature request: Add support for dataclasses #604

Dementiy opened this issue Feb 3, 2025 · 2 comments

Comments

@Dementiy
Copy link

Dementiy commented Feb 3, 2025

At the moment numpydoc will ignore "Attributes" section for dataclasses (or maybe I don't quite understand how to document dataclasses properly):

@dataclass
class Klass:
    """
    Klass description.

    Attributes
    ----------
    attr: int
        Some attribute description.
    """

    attr: int

It would be great to have such a feature.

@mattgebert
Copy link
Contributor

Whilst not directly related, I also notice that while the ability to track decorator functions has been added a while ago, specific support for the property decorator and it's subsequent getter, setter and deleter sub-functions are also not supported by numpydoc.

For example, after defining @property def myprop, the myprop.setter function decorator will still require a docstring for the setter function according to numpydoc, even though the docstring of the property class really ought to specify the whole property in one go. Usually there's only one reference/docstring point, so having a single docstring becomes a necessity.

Given these are standard library modules, can we implement module specific support?

I would be happy to give this a crack for both property attributes and dataclasses.

@mattgebert
Copy link
Contributor

mattgebert commented Feb 4, 2025

Also noticed this pull request related to long running issue #196 which touches on the use of type hinting to avoid requiring numpydoc to specify the type hinting with redundancy. This seems relevant for the dataclass decorator, where you are going to pull the implied constructor from the type hinting attributes.

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

No branches or pull requests

2 participants