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

Lines with power operator ** with simple operands are wrapped too early #3889

Closed
andersk opened this issue Sep 13, 2023 · 0 comments
Closed
Labels
T: bug Something isn't working

Comments

@andersk
Copy link

andersk commented Sep 13, 2023

Describe the bug

Black miscomputes the horizontal space required for lines containing the power operator ** with simple operands, and rewraps them much earlier than the expected 88-character line length. Perhaps that computation wasn’t adjusted for #538/#2726.

To Reproduce

Run Black with no arguments on this code (playground link):

x = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
y = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1

Black leaves the first line unaffected, but unexpectedly wraps the second vertically, even though its horizontal layout is only 56 characters long.

x = 1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1
y = (
    1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
    ** 1
)

Expected behavior

Both lines should be unchanged.

Environment

  • Black's version: 23.9.1
  • OS and Python version: Linux/Python 3.10.12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant