docformatter
docformatter copied to clipboard
Class attributes docstrings aren't formatted
Hi there,
I noticed that when declaring a class attribute with a docstring docformatter doesn't seem to take in account and reformat it.
An example:
class MyClass:
my_attribute: str
"""This is a very, very, very long docstring that should really be reformatted nicely by docformatter. But it is currently ignored and will stay on a very, very, very long line!"""
While I don't believe that class attribute docstrings are explicitly mentioned in an active PEP they are very common, and are for example supported by Sphinx, Numpydoc, mkdocstrings, and Pylance.
Per PEP-257, "The docstring for a class should summarize its behavior and list the public methods and instance variables." This can be found in the multi-line docstring section. Thus, PEP-257 treats class docstrings as multi-line docstrings and docformatter should format them as such.
I misread this issue. It is concerned with class attribute docstrings, not class docstrings. Class attribute docstrings are discussed in PEP 258, which is included in PEP 257 by reference. Since this request is for functionality not explicitly required by PEP 257, it is considered an enhancement, not a bug.