parse.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:static-typing 作者: mbdevpl 项目源码 文件源码
def parse(source: str, globals_=None, locals_=None, ast_module=typed_ast.ast3, *args, **kwargs):
    """Act like ast_module.parse() but also put static type info into AST."""

    if globals_ is None or locals_ is None:
        frame_info = inspect.getouterframes(inspect.currentframe())[1]
        caller_frame = frame_info[0]
        if globals_ is None:
            globals_ = caller_frame.f_globals
        if locals_ is None:
            locals_ = caller_frame.f_locals

    tree = ast_module.parse(source, *args, **kwargs)
    _LOG.debug('%s', ast_module.dump(tree))

    tree = augment(tree, globals_, locals_, ast_module)
    _LOG.debug('%s', ast_module.dump(tree))

    return tree
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号