Let black run on files even if ast.parse
with type_comments=True
fails
#3593
Labels
T: enhancement
New feature or request
ast.parse
with type_comments=True
fails
#3593
Is your feature request related to a problem? Please describe.
Right now, if a file parsing because of invalid type comments (even if the code runs just fine), black won't format the file.
For example:
While the code still runs:
Black no longer formats it:
This is because
ast.parse
on that code fails if you passtype_comments=True
:(Black does work if you do
black asd.py --fast
, as it no longer does the AST based check.)Describe the solution you'd like
If
ast.parse(..., type_comments=True)
fails for the before/after check, maybe doing it withtype_comments=False
is fine, just for that file?Describe alternatives you've considered
None so far.
Additional context
I don't think this can be considered an upstream bug, as this is indeed invalid syntax for a type checker's perspective. But black shouldn't care if the types are correct, in any way shape or form.
The text was updated successfully, but these errors were encountered: