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

Black trims whitespace around walrus operators in slices #3820

Closed
charliermarsh opened this issue Jul 29, 2023 · 3 comments · Fixed by #3823
Closed

Black trims whitespace around walrus operators in slices #3820

charliermarsh opened this issue Jul 29, 2023 · 3 comments · Fixed by #3823
Labels
S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: bug Something isn't working

Comments

@charliermarsh
Copy link
Contributor

Describe the bug

Black trims whitespace around := operators within slices. I'm not sure if this is a feature or a bug (if it's intended, feel free to close of course).

The behavior is similar to Black's treatment of : operators in slices as described here, but I can't tell if the same treatment is intentional for := operators.

To Reproduce

For example, given this code:

x[y := 1]

The formatted code is:

x[y:=1]

Similar to treatment of the : operator, Black does not reformat these:

x[(y := 1)]
x[y := f()]

Here's a playground link to demonstrate the above cases.

@charliermarsh charliermarsh added the T: bug Something isn't working label Jul 29, 2023
@JelleZijlstra
Copy link
Collaborator

That feels like a bug, we should add spaces here. PR welcome!

@JelleZijlstra JelleZijlstra added the S: accepted The changes in this design / enhancement issue have been accepted and can be implemented label Jul 29, 2023
@thomasjo
Copy link

Hey @JelleZijlstra I would like to work on this issue.

@Utkarshn10 it's already being worked on: #3823

@Utkarshn10
Copy link

Thanks for letting me know :)

Hey @JelleZijlstra I would like to work on this issue.

@Utkarshn10 it's already being worked on: #3823

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants