From: emfdavid <84335963+emfdavid@users.noreply.github.com> Date: Thu, 20 Jan 2022 23:48:49 +0000 (-0500) Subject: Hint at likely cause of ast parsing failure in error message (#2786) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/e66e0f8ff046e532e8129c78894ca1c4095c5c8b?ds=sidebyside 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> --- 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: