Hint at likely cause of ast parsing failure in error message (#2786)
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
This commit is contained in:
parent
6e97c5f47c
commit
e66e0f8ff0
@ -1312,7 +1312,10 @@ def assert_equivalent(src: str, dst: str, *, pass_num: int = 1) -> None:
|
|||||||
src_ast = parse_ast(src)
|
src_ast = parse_ast(src)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
raise AssertionError(
|
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
|
) from exc
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user