Parenthesize complex expressions passed as keyword arguments or parameter defaults #4925
+153
−31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In a nutshell, this PR turns
foo(bar=x + y), where the spacing looks confusing/illogical, intofoo(bar=(x + y)).The general idea is to make whitespace consistent with operator precedence - it is similar in spirit to #157 or #646.
See this short discussion for more details. A few developers agreed that the current formatting is "a little awkward" or would be "worthwhile to fix".
The proposed formatting already exists in a few places in the Black repository:
black/tests/data/cases/expression.py
Line 39 in c3cc5a9
black/tests/data/cases/expression.py
Line 181 in c3cc5a9
As well as in other popular Python projects:
I'm interested to hear what you think about this proposal!
PS. This PR shares some logic (
is_simple_exponentiation) with #4918. I will rebase one onto another if either is merged first.Checklist - did you ...
--previewstyle, following thestability policy?
CHANGES.mdif necessary?