def source_to_ast(source: str, file: str = None) -> ast.Module:
"""
Return node object for python source.
"""
if source and not isinstance(source, str):
raise TypeError('Unexpected type: {}'.format(str(type(source))))
return _call_with_frames_removed\
( ast.parse
, source = source
, filename = file or '<file>'
, mode = 'exec'
)
评论列表
文章目录