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

fix: Don't allow unparenthesizing walruses #4155

Merged
merged 6 commits into from
Jan 17, 2024
Merged

Conversation

cobaltt7
Copy link
Contributor

Description

Resolves #3758.

Checklist - did you ...

  • [y] Add an entry in CHANGES.md if necessary?
  • [y] Add / update tests if necessary?
  • [-] Add new / update outdated documentation?

cobaltt7 and others added 3 commits January 16, 2024 18:42
src/black/linegen.py Outdated Show resolved Hide resolved
@cobaltt7
Copy link
Contributor Author

It turns out that adding that check to maybe_make_parens_invisible_in_atom causes Black to add parenthesis around walruses where it's unnecessary. See the test failure (we didn't notice it previously since that test doesn't run with --preview). I moved the check to visit_dictsetmaker() where we can be sure it won't affect anything else.

Copy link
Collaborator

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@JelleZijlstra JelleZijlstra merged commit 9a331d6 into psf:main Jan 17, 2024
45 of 46 checks passed
@wizpig64
Copy link

Thanks @RedGuy12 for fixing my bug!

@cobaltt7 cobaltt7 deleted the gh-3758 branch January 18, 2024 03:29
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.

cannot parse assignment expression in preview style since 23.1
3 participants