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

Contra docs, Black does not add backslashes for multiple context manages #2118

Closed
Zac-HD opened this issue Apr 19, 2021 · 2 comments
Closed
Labels
T: bug Something isn't working T: documentation Improvements to the docs (e.g. new topic, correction, etc)

Comments

@Zac-HD
Copy link
Contributor

Zac-HD commented Apr 19, 2021

https://black.readthedocs.io/en/latest/the_black_code_style.html says:

Black always gets rid of backslashes, [with] one exception: with statements using multiple context managers. Python’s grammar does not allow organizing parentheses around the series of context managers.

We don’t want formatting like:

with make_context_manager1() as cm1, make_context_manager2() as cm2, make_context_manager3() as cm3, make_context_manager4() as cm4:
    ...  # nothing to split on - line too long

So Black will now format it like this:

with \
     make_context_manager(1) as cm1, \
     make_context_manager(2) as cm2, \
     make_context_manager(3) as cm3, \
     make_context_manager(4) as cm4 \
:
    ...  # backslashes and an ugly stranded colon

but Black 20.8b1 doesn't make any changes to the input line.

@Zac-HD Zac-HD added the T: bug Something isn't working label Apr 19, 2021
@ichard26 ichard26 added the T: documentation Improvements to the docs (e.g. new topic, correction, etc) label Apr 20, 2021
@ichard26
Copy link
Collaborator

ichard26 commented Apr 20, 2021

Sigh, this issue has been noted before:

[...] I dislike that we advertise that Black handles with statements in a sane manner in the documentation, yet none of the work needed for any of it has seen the light of day. Doing documentation-driven development is good, but I think we're sending the wrong signal if the actual development ends up never finished. But, just my opinion, shrugs.

by @ichard26 (i.e. me!) #1948 (comment)

This will be fixed once I finish up the documentation reorganization effort I'm doing, but I've been slow.

Thanks for opening a tracking issue for it, this is something we don't wanna forget!

@felix-hilden
Copy link
Collaborator

The documentation reorganisation has been done, and the information is now in The future of the Black code style. Can this issue be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working T: documentation Improvements to the docs (e.g. new topic, correction, etc)
Projects
None yet
Development

No branches or pull requests

4 participants