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

Docstring reformatting causes line to be too long #3331

Closed
adamjstewart opened this issue Oct 16, 2022 · 2 comments
Closed

Docstring reformatting causes line to be too long #3331

adamjstewart opened this issue Oct 16, 2022 · 2 comments
Labels
F: docstrings How we format docstrings R: outdated Resolved or not relevant anymore. T: bug Something isn't working

Comments

@adamjstewart
Copy link

Describe the bug

Black is overzealous about reformatting docstrings to a single line, and can cause the resulting line to be longer than the line length limit.

To Reproduce

For example, take this code:

def f():
    """89 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678
    """

The first line of this docstring is exactly 88 characters. After blackening this code, this results in:

def f():
    """89 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678"""

The line is now 91 characters, and flake8 complains.

Expected behavior

Honestly, I wouldn't expect black to reformat docstrings at all. But I definitely wouldn't expect it to reformat to the point where style-compliant code becomes non-style-compliant.

Environment

  • Black's version: 22.10.0, main
  • OS and Python version: macOS 12.6, Python 3.9.13

Additional context

This appears to be a regression of the same bug reported in #1632 and #2274.

@adamjstewart adamjstewart added the T: bug Something isn't working label Oct 16, 2022
@felix-hilden felix-hilden added the F: docstrings How we format docstrings label Oct 16, 2022
@felix-hilden
Copy link
Collaborator

With the "preview" toggle enabled, this is fixed. Also worth mentioning that we're discussing the exact opposite behavior in #3320.

@adamjstewart
Copy link
Author

Thanks, glad to know it's already been fixed!

@felix-hilden felix-hilden added R: duplicate This issue or pull request already exists R: outdated Resolved or not relevant anymore. and removed R: duplicate This issue or pull request already exists labels Oct 16, 2022
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 R: outdated Resolved or not relevant anymore. T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants