-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
trailing space after parenthesized walrus operator #1522
Comments
On closer reading through the PEP, I don’t see why (val := expr) shouldn’t be transformed into val := expr. They seem to be equivalent as far as I can tell (in the context of an if-conditional). The only cases where that transformation is not valid are in top-level statements and such. |
We definitely shouldn't put a space before the colon, that's a bug. I'm not as sure we should remove the parentheses, maybe it's better for clarity to have them? Black is opinionated, but we should make sure we're opinionated in the right way. |
@JelleZijlstra black does convert And there are multiple examples in the PEP that omit the parentheses when there is no RHS. |
The title of this issue, which I'd take as the primary point of this issue, is a duplicate of #1174. I suggest closing this issue as a duplicate and opening a new issue just for discussing whether assignment expressions in ifs should be contained in parentheses. |
I agree and I've done that (see #1656). Thanks! |
Consider this snippet (as produced after running Black):
Ideally, Black would remove the redundant parentheses (although I realize this is pretty hard to do).
However, why does Black insist on the single space before the terminating colon? This causes flake8 to complain (and rightly so I feel).
I skimmed through the PEP and I can’t seem to find any example where that space is used. Is this a deliberate design decision?
The text was updated successfully, but these errors were encountered: