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 new line reformatting can violate line length constraint #2274

Closed
DrGFreeman opened this issue May 29, 2021 · 3 comments
Closed

Docstring new line reformatting can violate line length constraint #2274

DrGFreeman opened this issue May 29, 2021 · 3 comments
Labels
F: strings Related to our handling of strings R: duplicate This issue or pull request already exists T: bug Something isn't working

Comments

@DrGFreeman
Copy link

DrGFreeman commented May 29, 2021

Describe the bug

Removal of new line in docstrings can violate the line length constraint if the last line is within two characters of the max line length value.

To Reproduce Steps to reproduce the behavior:

Run black on the following code with the default line-length constraint of 88 characters.

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

Expected behavior

No reformatting is performed.

Actual behavior

The code is reformatted as shown below, which violates the max line length constraint.

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

In a CI setup with Flake8 running after black, Flake8 throws the following error:

test.py:2:89: E501 line too long (91 > 88 characters)

Environment (please complete the following information):

  • All versions of black from 20.8b0 up to 21.5b1 as well as main (d3670d9).
  • Reproduced on Windows 10 & Ubuntu 18.04/20.04, Python 3.7 & 3.8

Does this bug also happen on main?

Yes

Additional context

black 19.10b0 does not have this behavior.
This was reported in #1635 (comment).

@DrGFreeman DrGFreeman changed the title Docstring new line reformatting can violate line length contraint Docstring new line reformatting can violate line length constraint May 29, 2021
@ichard26 ichard26 added F: strings Related to our handling of strings T: bug Something isn't working R: duplicate This issue or pull request already exists labels May 29, 2021
@ichard26
Copy link
Collaborator

I'll be closing this since this is a duplicate of GH-1632, thank you for the report though!

@DrGFreeman
Copy link
Author

Oh! I should have checked before. My bad. Sorry for wasting your time 😓

@ichard26
Copy link
Collaborator

Don't worry about it, we do happen to have 250+ issues so it can be (very) annoying to discover whether your issue has been already reported or not. It's my job as a triager to catch the mistakes anyhow :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: strings Related to our handling of strings R: duplicate This issue or pull request already exists T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants