Field docstrings components are now inherited from the base classes.
@dataclass
class Base:
bar: int = 123 # inline
"""field docstring from base class"""
@dataclass
class Foo(Base):
Above
bar: int = 123 # The bar property
assert get_attribute_docstring(Foo, "bar") == AttributeDocString(
comment_inline="The bar property",
comment_above="Above",
docstring_below="field docstring from base class",
)
--help text:
usage: pytest [-h] [--bar int]
optional arguments:
-h, --help show this help message and exit
Foo ['foo']:
Foo(bar: int = 123)
--bar int field docstring from base class (default: 123)
@dataclass class Foo(Base):
Above
assert get_attribute_docstring(Foo, "bar") == AttributeDocString( comment_inline="The bar property", comment_above="Above", docstring_below="field docstring from base class", )
usage: pytest [-h] [--bar int]
optional arguments: -h, --help show this help message and exit
Foo ['foo']: Foo(bar: int = 123)
--bar int field docstring from base class (default: 123)