[New-bugs-announce] [issue38401] Make dataclass attribute docstrings accessible

John Parejko report at bugs.python.org
Mon Oct 7 20:24:53 EDT 2019


New submission from John Parejko <parejkoj at uw.edu>:

Dataclasses provide a very straightforward way to specify structured data. One can trivally document a dataclass's attributes via triple-quoted attribute docstrings per PEP 257. However, those docstrings are not accessible to pydoc, so they are lost to users of the dataclass.

For example, the attribute docstrings in the below dataclass should be available when looking at `help(SpectralData)`, but that help command does not show the docstrings.

```
@dataclasses.dataclass
class SpectralData:
    """Class to hold data and metadata from a fiber spectrograph."""
    wavelength: astropy.units.Quantity
    """The wavelength array produced by the instrument."""
    spectrum: np.ndarray
    """The flux array in instrumental units."""
    duration: float
    """The duration of the exposure in seconds."""
```

----------
assignee: docs at python
components: Documentation
messages: 354154
nosy: John Parejko2, docs at python
priority: normal
severity: normal
status: open
title: Make dataclass attribute docstrings accessible
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38401>
_______________________________________


More information about the New-bugs-announce mailing list