Closed Yoshanuikabundi closed 6 months ago
Is it worth removing existing : str, optional, default=None
from docstrings (in addition to adding relevant annotations)? I originally thought no on the basis that removing something that works is bad, but after a few days I've come around to thinking it's worth it.
None
Yes, I think we should definitely remove any information from docstrings that's duplicated in the signature. In addition to the points you mention, docstrings go out of date really fast - every time I go over the docs of any project I find incorrect docstrings.
Documentation builders work just as fine with either (I think? Is one better?)
Annotations are generally better as they reliably appear in the signature, rather than just in the text - and importantly, are much more testable.
I think any one of these issues is enough to convince me, all of them together makes me very confident that docstrings should not include information duplicated from the signature.
I mostly implemented this yesterday; it felt like sending one's favorite cattle out to pasture, if even for the better.
The only concern I had was how to communicate the default value - I'm not sure how best to do it, and if I can con you into being the reviewer for these changes you'll see there
I don't think we'll be able to do this in a single PR, but it would be good to consolidate all type information in signatures and type annotations, rather than docstrings. Sphinx is still able to present these types, and having them be actually type checked makes more documentation testable.