-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Describe the bug A clear and concise description of what the bug is.
Black fails to parse with statements that are both parenthesized and use as such as with (open("a", "w") as a):. I found this while noting that black would not reformat an overly long line of the form with a as b, x as y:.
To Reproduce Steps to reproduce the behavior:
with open("a", "w"):
pass
with open("a", "w") as a:
pass
with (open("a", "w")):
pass
with (open("a", "w") as a):
passCannot parse: 10:21: with (open("a", "w") as a):
Expected behavior A clear and concise description of what you expected to happen.
I expect that black does not fail to parse and also reformats as needed when the line is too long. Reformatting would include adding parentheses and wrapping such as below (for actually too-long lines).
with (
open("c", "w") as a,
open("d", "w") as b,
):Environment (please complete the following information):
- Version: 20.8b1 and 71117e7
- OS and Python version: Locally with Linux and Python 3.9.1, also whatever black.now.sh is running right now
Does this bug also happen on master? To answer this, you have two options:
yes
Additional context Add any other context about the problem here.
Perhaps I should enter two bugs. One for the parsing failure and one for the lack of willingness to add parentheses and reformat. Or perhaps they are sufficiently intertwined... let me know if I need to file a second issue.