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

Force parentheses between unary op and binary power. #909

Merged
merged 4 commits into from
Jun 29, 2019
Merged

Force parentheses between unary op and binary power. #909

merged 4 commits into from
Jun 29, 2019

Conversation

brandtbucher
Copy link
Contributor

Fixes #646. This patch forces expressions containing unary and power ops, like this...

+a ** -b ** ~c ** -d  # This is legal blackened code.

...to be reformatted with parentheses to make operator precedence clear, like this...

+(a ** -(b ** ~(c ** -d)))  # This is legal blackened code.

@brandtbucher
Copy link
Contributor Author

The two remaining mypy errors are due to #907, unrelated.

@brandtbucher
Copy link
Contributor Author

Is there anything more I need to do for this? This is my first time contributing, so I'm not sure if I missed something!

@JelleZijlstra JelleZijlstra merged commit b073c9a into psf:master Jun 29, 2019
@brandtbucher
Copy link
Contributor Author

Thanks!

ambv added a commit that referenced this pull request Oct 28, 2019
This was caused by an overly liberal application of parentheses in #909 that
fixed #646.

Fixes #1041
charliermarsh added a commit to astral-sh/ruff that referenced this pull request 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

combination of unary and power operator leads to misleading formatting.
2 participants