Skip to content
Open
8 changes: 6 additions & 2 deletions src/black/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ def lib2to3_parse(
faulty_line = lines[lineno - 1]
except IndexError:
faulty_line = "<line number missing in source>"
errors[grammar.version] = InvalidInput(
f"Cannot parse{tv_str}: {lineno}:{column}: {faulty_line}"
caret_line = "^".rjust(column)
message = (
f"SyntaxError is in line {lineno}, column {column}:\n"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use wording similar to how it was previously, this message is confusing (and spelled wrong)!

Please also review the test failures.

f" {faulty_line}\n"
f" {caret_line}"
)
errors[grammar.version] = InvalidInput(message)

except TokenError as te:
# In edge cases these are raised; and typically don't have a "faulty_line".
Expand Down
Loading