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

Wrap multiple context managers in parens when targeting Python 3.10+ #3486

Closed
yilei opened this issue Jan 9, 2023 · 0 comments · Fixed by #3489
Closed

Wrap multiple context managers in parens when targeting Python 3.10+ #3486

yilei opened this issue Jan 9, 2023 · 0 comments · Fixed by #3489
Labels
S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?

Comments

@yilei
Copy link
Contributor

yilei commented Jan 9, 2023

So that we actually implement https://black.readthedocs.io/en/stable/the_black_code_style/future_style.html#using-backslashes-for-with-statements:

Although when the target version is Python 3.9 or higher, Black will use parentheses instead since they’re allowed in Python 3.9 and higher.

I'll work on a PR to implement this when targeting Python 3.9+ 3.10+ (since it's only officially allowed in 3.10 https://docs.python.org/3/whatsnew/3.10.html#parenthesized-context-managers, though accidentally enabled in Python 3.9 with the new parser). (per discussion, enabling it for Python 3.9+ should be fine in practice)

Note: #2926 is related.

@yilei yilei added the T: style What do we want Blackened code to look like? label Jan 9, 2023
@JelleZijlstra JelleZijlstra added the S: accepted The changes in this design / enhancement issue have been accepted and can be implemented label Jan 9, 2023
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: style What do we want Blackened code to look like?
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants