From 28c9ffae6bfad33a1f0114928e4240916664a21a Mon Sep 17 00:00:00 2001 From: David Stuebe Date: Wed, 19 Jan 2022 22:52:07 -0500 Subject: [PATCH 1/4] Hint at likely cause of ast parsing failure in error message --- src/black/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index 405a01082e7..c851ff71991 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -1315,7 +1315,9 @@ 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: {exc}" + 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: From 28d2f329d13b80cbdce0d0a6be6b2abd81487356 Mon Sep 17 00:00:00 2001 From: emfdavid <84335963+emfdavid@users.noreply.github.com> Date: Thu, 20 Jan 2022 11:10:49 -0500 Subject: [PATCH 2/4] Update src/black/__init__.py That works. Co-authored-by: Batuhan Taskaya --- src/black/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index c851ff71991..8abbf19d8c8 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -1315,7 +1315,7 @@ 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 AST: {exc}" + f"cannot use --safe with this file; failed to parse source file AST: {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 10308c07da23780968452883925e23418afd5e16 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 20 Jan 2022 09:11:19 -0800 Subject: [PATCH 3/4] Update src/black/__init__.py --- src/black/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index 8abbf19d8c8..a8fff32f222 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -1315,7 +1315,8 @@ 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 AST: {exc}\n" + 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 50506bd9b826efd8c479363acecdd0da26298969 Mon Sep 17 00:00:00 2001 From: Richard Si <63936253+ichard26@users.noreply.github.com> Date: Thu, 20 Jan 2022 18:39:45 -0500 Subject: [PATCH 4/4] Capitialization nits --- src/black/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index a8fff32f222..d201ce55cb7 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -1317,7 +1317,7 @@ def assert_equivalent(src: str, dst: str, *, pass_num: int = 1) -> None: raise AssertionError( 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"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