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

problem parsing with statements #3678

Open
15r10nk opened this issue May 4, 2023 · 1 comment
Open

problem parsing with statements #3678

15r10nk opened this issue May 4, 2023 · 1 comment
Labels
T: bug Something isn't working

Comments

@15r10nk
Copy link

15r10nk commented May 4, 2023

Some with statements can not be parsed by black.
They are unlikely to appear in real code, but they are valid python and can be parsed by cpython.

Examples

with (name_2 for name_0 in name_4):
    pass
with (a,*b):
    pass

None of these examples have a valid __enter__ or __exit__ and should fail at runtime.

black gives the following error:

error: cannot format example4.py: Cannot parse: 1:8: with a, *b:

Oh no! 💥 💔 💥
1 file failed to reformat.

Expected behavior

black should be able to parse and format this statements.

Environment

python -m black, 23.3.1.dev10+geb32729 (compiled: no)
Python (CPython) 3.11.3

@15r10nk 15r10nk added the T: bug Something isn't working label May 4, 2023
@JelleZijlstra
Copy link
Collaborator

Presumably related to #2926, and fixable by changing remove_with_parens() in linegen.py.

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
Projects
None yet
Development

No branches or pull requests

2 participants