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

Hint at likely cause of ast parsing failure in error message #2786

Merged
merged 4 commits into from Jan 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/black/__init__.py
Expand Up @@ -1315,7 +1315,10 @@ def assert_equivalent(src: str, dst: str, *, pass_num: int = 1) -> None:
src_ast = parse_ast(src)
except Exception as exc:
raise AssertionError(
f"cannot use --safe with this file; failed to parse source file: {exc}"
f"cannot use --safe with this file; failed to parse source file AST: "
f"{exc}\n"
f"This could be caused by running Black with an older Python version "
f"that does not support new syntax used in your source file."
) from exc

try:
Expand Down