feat(cli): 编译期错误按 Viper 模拟堆栈输出
TypeError/SyntaxError 输出 Traceback (compile-time) + File/line + 源码行 + Err,不再打印 Python 内部调用链。
This commit is contained in:
1 parent
2d0ab9c11f
commit
7911b4de54
2 files changed
+22
-1
No files matched your search
@@ -92,6 +92,10 @@ def parse_python_file(filepath: str) -> tuple[str, ast.Module] | tuple[str, None
|
||||
tree: ast.Module = ast.parse(ExpandSoftKeywords(content), filepath)
|
||||
except SyntaxError:
|
||||
return (content, None)
|
||||
except TypeError as _e:
|
||||
if not getattr(_e, 'Filename', ''):
|
||||
_e.Filename = filepath
|
||||
raise
|
||||
_FILE_AST_CACHE[norm_path] = (mtime, content, tree)
|
||||
return (content, tree)
|
||||
|
||||
|
||||
Reference in new issue
Block a user