PEP681 introduced dataclass_transform
, a decorator for marking objects with dataclass
-like behavior, available in python3.11+.
Griffe incorrectly warns about missing parameters of such objects' docstrings.
# helloclass.py
from dataclasses import dataclass
from typing import dataclass_transform
@dataclass_transform()
class HelloDataClass:
"""A dataclass which says 'Hello' on creation."""
def __init_subclass__(cls) -> None:
"""Say hello."""
print("Hello")
dataclass(cls)
class HelloPerson(HelloDataClass):
"""A person with name and age.
Parameters
----------
name : str
age : int
"""
name: str
age: int
# mkdocs.yaml
site_name: hello
nav:
- Home: index.md
plugins:
- mkdocstrings:
default_handler: python
handlers:
python:
options:
docstring_style: numpy
<!-- docs/index.md -->
::: helloclass
$ mkdocs build
INFO - Cleaning site directory
INFO - Building documentation to directory: /tmp/site
WARNING - griffe: helloclass.py:21: Parameter 'name' does not appear in the
function signature
WARNING - griffe: helloclass.py:21: Parameter 'age' does not appear in the
function signature
INFO - Documentation built in 0.21 seconds
A class which inherits from a base decorated with dataclass_transform
, or itself decorated by a decorator decorated by dataclass_transform
, should not warn about missing parameters in function signature.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too