11import ast
22import inspect
33import astunparse
4- from typing import Any , Dict , List , Optional , Sequence , Tuple
4+ from typing import Any , Dict , List , Optional , Sequence , Tuple , Union
55
66from dlt .common .typing import AnyFun
77
88
9- def get_literal_defaults (node : ast .FunctionDef ) -> Dict [str , str ]:
9+ def get_literal_defaults (node : Union [ ast .FunctionDef , ast . AsyncFunctionDef ] ) -> Dict [str , str ]:
1010 """Extract defaults from function definition node literally, as pieces of source code"""
1111 defaults : List [ast .expr ] = []
1212 if node .args .defaults :
@@ -30,12 +30,12 @@ def get_literal_defaults(node: ast.FunctionDef) -> Dict[str, str]:
3030 return literal_defaults
3131
3232
33- def get_func_def_node (f : AnyFun ) -> ast .FunctionDef :
33+ def get_func_def_node (f : AnyFun ) -> Union [ ast .FunctionDef , ast . AsyncFunctionDef ] :
3434 """Finds the function definition node for function f by parsing the source code of the f's module"""
3535 source , lineno = inspect .findsource (inspect .unwrap (f ))
3636
3737 for node in ast .walk (ast .parse ("" .join (source ))):
38- if isinstance (node , ast .FunctionDef ):
38+ if isinstance (node , ast .FunctionDef ) or isinstance ( node , ast . AsyncFunctionDef ) :
3939 f_lineno = node .lineno - 1
4040 # get line number of first decorator
4141 if node .decorator_list :
0 commit comments