Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black should format docstring line length #2865

Closed
danohn opened this issue Feb 3, 2022 · 7 comments
Closed

Black should format docstring line length #2865

danohn opened this issue Feb 3, 2022 · 7 comments
Labels
F: docstrings How we format docstrings F: linebreak How should we split up lines? F: linetoolong Black makes our lines too long T: style What do we want Blackened code to look like?

Comments

@danohn
Copy link

danohn commented Feb 3, 2022

Describe the style change

Black should format docstring line length.

Examples in the current Black style

def my_func():
    """
    This is a really long docstring. This is a really long docstring. Th
is is a really long docstring. This is a really long docstring. This is a really long docstring. This is a really long docstring.
    """
    pass

Desired style

def my_func():
    """
    This is a really long docstring. This is a really long docstring. Th
is is a really long docstring. This is a really long docstring. Thi
s is a really long docstring. This is a really long docstring.
    """
    pass
@danohn danohn added the T: style What do we want Blackened code to look like? label Feb 3, 2022
@hukkin
Copy link
Contributor

hukkin commented Feb 3, 2022

docformatter already exists. IMO would be great if Black didn't alter AST any more than it already does.

@ichard26 ichard26 added F: strings Related to our handling of strings F: linebreak How should we split up lines? F: linetoolong Black makes our lines too long labels Feb 3, 2022
@ubalklen
Copy link

Not saying this should be solved by Black, but docformatter will only help so much. Their line wrapper only applies to simple docstrings, so if you're using Google style docstrings, you're out of luck.

@felix-hilden
Copy link
Collaborator

Yeah, this has been a pain point in #2150.

@ubalklen this could be a feature request to docformatter.

@ubalklen
Copy link

@felix-hilden they have an open issue already. I just mentioned that here in case there are other lost souls out there expecting to find some auto formatting tool for their non-standard docstrings. The current state of affairs is: Black won't (and maybe shouldn't) help you with this. And docformatter should, but won't help you at this time.

@felix-hilden
Copy link
Collaborator

Related to #2289

@felix-hilden felix-hilden added F: docstrings How we format docstrings and removed F: strings Related to our handling of strings labels Aug 29, 2022
@simonprovost
Copy link

@felix-hilden they have an PyCQA/docformatter#60 already. I just mentioned that here in case there are other lost souls out there expecting to find some auto formatting tool for their non-standard docstrings. The current state of affairs is: Black won't (and maybe shouldn't) help you with this. And docformatter should, but won't help you at this time.

+1

@JelleZijlstra
Copy link
Collaborator

I am going to say that reflowing docstrings is out of scope for Black. It's likely to break some use cases (e.g., embedded code in docstrings), it may produce ugly output (just one word on the next line), and if we reflow too aggressively it can make diffs harder to read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: docstrings How we format docstrings F: linebreak How should we split up lines? F: linetoolong Black makes our lines too long T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

7 participants