New submission from John Parejko <parej...@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@python
components: Documentation
messages: 354154
nosy: John Parejko2, docs@python
priority: normal
severity: normal
status: open
title: Make dataclass attribute docstrings accessible
type: enhancement

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38401>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to