From e66e0f8ff046e532e8129c78894ca1c4095c5c8b Mon Sep 17 00:00:00 2001 From: emfdavid <84335963+emfdavid@users.noreply.github.com> Date: Thu, 20 Jan 2022 18:48:49 -0500 Subject: [PATCH] Hint at likely cause of ast parsing failure in error message (#2786) Co-authored-by: Batuhan Taskaya Co-authored-by: Jelle Zijlstra Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com> --- src/black/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index 67c272e..bdece68 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -1312,7 +1312,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: -- 2.39.5