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

Dataclasses syntax #58

Closed
nrbnlulu opened this issue Feb 1, 2023 · 5 comments
Closed

Dataclasses syntax #58

nrbnlulu opened this issue Feb 1, 2023 · 5 comments
Labels
feature New feature or request

Comments

@nrbnlulu
Copy link

nrbnlulu commented Feb 1, 2023

Describe the bug

@dataclass
class Foo:
    bar: str
    """documentation for bar"""

Here bar is recognized by mkdocstring-python as a class-variable, it should parsed like arguments

Screenshots
image

While this is what I would expect:
image

Note that when implementing this any library that uses PEP 681 should treated the same

@pawamoy
Copy link
Member

pawamoy commented Feb 3, 2023

I don't disagree 🙂 I'll have to see if there are special cases to handle though.
In the meantime you can document these dataclass attributes with a Parameters section in the class' docstring itself:

@dataclass
class Foo:
    """blabla

    Parameters:
        bar: documentation for bar
    """

    bar: str

@gilfree
Copy link
Contributor

gilfree commented Feb 19, 2023

Hi, What is your opinion about supporting not just dataclasses but all the dataclass-like objects as defined in https://peps.python.org/pep-0681/ ?

That will cover at least dataclasses, attrs and pydantic objects

@pawamoy
Copy link
Member

pawamoy commented Feb 19, 2023

I'd have to read the PEP more carefully, but once we get inheritance working it should be possible yes.

@pawamoy pawamoy added the feature New feature or request label Mar 5, 2023
@pawamoy
Copy link
Member

pawamoy commented Nov 12, 2023

You might be interested in this Griffe extension: https://github.com/tlambert03/griffe-fieldz

@pawamoy
Copy link
Member

pawamoy commented Apr 12, 2024

Griffe recently added much better support for dataclasses, this should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants