custom_hypothesis_support.py 文件源码

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

项目:pyta 作者: pyta-uoft 项目源码 文件源码
def _parse_text(source: Union[str, NodeNG]) -> Tuple[astroid.Module, TypeInferer]:
    """Parse source code text and output an AST with type inference performed."""
    # TODO: apparently no literal syntax for empty set in Python3, also cannot do set()
    # TODO: Deal with special case later.
    # if isinstance(source, astroid.Set) and len(list(source.elts)) == 0:
    #     source = f'{set({})}'
    if not isinstance(source, str):  # It's an astroid node
        source = source.as_string()
    module = astroid.parse(source)
    type_inferer = TypeInferer()
    type_inferer.environment_transformer().visit(module)
    type_inferer.type_inference_transformer().visit(module)
    return module, type_inferer
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号