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
Black produced invalid code: assert (*x)
#921
Comments
I agree lib2to3 shouldn't accept this. There's a certain class of these python programs that are technically invalid python to start with, so Black is at a severe disadvantage of dealing with. I don't think this is super important to fix in Black as it will usually generate invalid code (like above) and then fail promptly. I can't come up with an example that's all of:
This would be bad as Black would hide the fact that the original code was not valid Python and thus all bets are off, but as a user of Black it's very hard to tell there was an error in the first place. |
I think it still would be nice to show a "Cannot parse" message instead of "INTERNAL ERROR, please report a bug". |
I agree with @zsol, there are numerous of examples where black can parse but CPython can't parse (or rather don't accept as input). The current error message seems to be better though:
|
Thanks, closing as the current behavior seems fine. |
Operating system: macOS Mojave 10.14.5 (18F132)
Python version: Python 3.7.3
Black version: 19.3b0 (f3bb22a)
Does also happen on master: yes
Minified reproducer:
Stack trace:
This is invalid python code that gets accepted by
blib2to3
grammar. I think black should throwInvalidInput
exception in this case, notAssertionError
.Maybe it's worth raising an upstream bug for
lib2to3
?The text was updated successfully, but these errors were encountered: