def func_to_ast(func: types.FunctionType, file: str = None) -> ast.Module:
"""
Return node object for function.
"""
if func and not isinstance(func, types.FunctionType):
raise TypeError('Unexpected type: {}'.format(str(type(func))))
result = None
if func and hasattr(func, '__code__'):
result = code_to_ast(func.__code__, file)
return result
评论列表
文章目录