You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For what it's worth, I'm not sure if this is actually intended behavior or not, but it doesn't seem like it. No other parenthesized expressions in if statements get this treatment.
To Reproduce:
Put this example in a file:
if (foo:=True):
print(foo)
Run black <file> --diff
Expected behavior
Black should not need to act upon this file. There should be no diff output and black should claim 1 file would be left unchanged.
Actual behavior
Black currently inserts a space between the end of the assignment expression and the colon.
OS and Python version: Windows 10 and Linux tested with Python 3.8.0
Does this bug also happen on master?
Yes
Other Information
This also affects if statements that are broken up into several lines.
The following example comes come a current project, excuse the specificity. The # pylint: disable=superfluous-parens should be treated simply as a comment for the scope of this issue. (In reality, pylint is also currently having a problem with assignment expressions)
classFoo:
defmethod(self):
if (
invalid_reasons:=self.invalid_reasons()
): # pylint: disable=superfluous-parensLOGGER.error(
f"Not saving raid for the following reasons: {', '.join(invalid_reasons)}"
)
return
--- blacktest.py 2019-11-23 01:07:27.116369 +0000+++ blacktest.py 2019-11-23 01:07:30.956945 +0000@@ -1,10 +1,10 @@
class Foo:
def method(self):
if (
invalid_reasons := self.invalid_reasons()
- ): # pylint: disable=superfluous-parens+ ) : # pylint: disable=superfluous-parens
LOGGER.error(
f"Not saving raid for the following reasons: {', '.join(invalid_reasons)}"
)
return
The text was updated successfully, but these errors were encountered:
Description
Black on the current master@c53853f and (19.10b0) adds a space after Assignment Expressions and before the final colon in
if
statements.For what it's worth, I'm not sure if this is actually intended behavior or not, but it doesn't seem like it. No other parenthesized expressions in
if
statements get this treatment.To Reproduce:
black <file> --diff
Expected behavior
Black should not need to act upon this file. There should be no diff output and black should claim
1 file would be left unchanged.
Actual behavior
Black currently inserts a space between the end of the assignment expression and the colon.
Actual
black <file> --diff
output:Environment:
Does this bug also happen on master?
Yes
Other Information
This also affects
if
statements that are broken up into several lines.The following example comes come a current project, excuse the specificity. The
# pylint: disable=superfluous-parens
should be treated simply as a comment for the scope of this issue. (In reality, pylint is also currently having a problem with assignment expressions)The text was updated successfully, but these errors were encountered: