From 849f34b6fc329230854518c4c9679c0845b44b8b Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Mon, 18 Sep 2023 14:41:39 +0200 Subject: [PATCH] Log specific message when `ParserSyntaxError` happens (#128) --- bump_pydantic/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bump_pydantic/main.py b/bump_pydantic/main.py index d0ce713..26cda8d 100644 --- a/bump_pydantic/main.py +++ b/bump_pydantic/main.py @@ -196,6 +196,12 @@ def run_codemods( fp.write(output_code) fp.truncate() return None, None + except cst.ParserSyntaxError: + return ( + f"A syntax error happened on {filename}. This file cannot be formatted.\n" + "Check https://github.com/pydantic/bump-pydantic/issues/124 for more information.\n" + f"{traceback.format_exc()}" + ), None except Exception: return f"An error happened on {filename}.\n{traceback.format_exc()}", None