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