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

Add parentheses around power operations #7951

Closed
konstin opened this issue Oct 13, 2023 · 2 comments · Fixed by #7955
Closed

Add parentheses around power operations #7951

konstin opened this issue Oct 13, 2023 · 2 comments · Fixed by #7955
Assignees
Labels
bug Something isn't working formatter Related to the formatter

Comments

@konstin
Copy link
Member

konstin commented Oct 13, 2023

Ours:

self.assertRaises(IndexError, lambda: b[-10**100])

Black:

self.assertRaises(IndexError, lambda: b[-(10**100)])

We should implement the same rules as black to add parentheses around power operations.

@konstin konstin added bug Something isn't working formatter Related to the formatter labels Oct 13, 2023
@charliermarsh
Copy link
Member

Is this documented anywhere in the style guide?

@charliermarsh
Copy link
Member

Maybe this? psf/black#909

@charliermarsh charliermarsh self-assigned this Oct 13, 2023
charliermarsh added a commit that referenced this issue Oct 16, 2023
## Summary

E.g., given `-10**100`, reformat as `-(10**100)`.

Black special cases this (psf/black#909) and
it's currently a deviation.

Closes #7951.
@MichaReiser MichaReiser added this to the Formatter: Beta milestone Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working formatter Related to the formatter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants