black icon indicating copy to clipboard operation
black copied to clipboard

Docstrings should be forced to use triple quotes

Open dougthor42 opened this issue 6 years ago • 2 comments

Operating system: Windows 10 Pro 1809 + WSL (Ubuntu 18.04.2 LTS) Python version: 3.6.7 Black version: 19.0b3 Does also happen on master: yes (via online formatter)

Related: #144.

Even if #144 is not implemented, Black should update docstrings to be triple double quotes.

def foo():
    "Hello"
    pass

# formats to:
def foo():
    """Hello"""
    pass

Thoughts?

dougthor42 avatar Aug 13 '19 22:08 dougthor42

This is indeed what PEP 257 is suggesting. My only concern is what happens if this pushes the docstring over the line (e.g. makes it too long).

In any case, we will be deciding what to do about it as part of #144. Thanks!

ambv avatar Mar 04 '20 21:03 ambv

@ambv can we re-open this? it looks like it wasn't addressed as part of https://github.com/psf/black/issues/144#issuecomment-628137144

graingert avatar Nov 19 '20 16:11 graingert