@@ -33,8 +33,10 @@ def __init__(
33
33
def visit_ClassDef (self , node : ast .ClassDef ) -> ast .ClassDef :
34
34
self .context_stack .append (node .name )
35
35
for inner_node in node .body :
36
- if isinstance (inner_node , ( ast .FunctionDef , ast . AsyncFunctionDef ) ):
36
+ if isinstance (inner_node , ast .FunctionDef ):
37
37
self .visit_FunctionDef (inner_node )
38
+ elif isinstance (inner_node , ast .AsyncFunctionDef ):
39
+ self .visit_AsyncFunctionDef (inner_node )
38
40
self .context_stack .pop ()
39
41
return node
40
42
@@ -50,14 +52,14 @@ def get_comment(self, match_key: str) -> str:
50
52
return f"# { format_time (original_time )} -> { format_time (optimized_time )} ({ perf_gain } % { status } )"
51
53
52
54
def visit_FunctionDef (self , node : ast .FunctionDef ) -> ast .FunctionDef :
53
- return self ._process_function_def (node )
55
+ self ._process_function_def_common (node )
56
+ return node
54
57
55
58
def visit_AsyncFunctionDef (self , node : ast .AsyncFunctionDef ) -> ast .AsyncFunctionDef :
56
- return self ._process_function_def (node )
59
+ self ._process_function_def_common (node )
60
+ return node
57
61
58
- def _process_function_def (
59
- self , node : ast .FunctionDef | ast .AsyncFunctionDef
60
- ) -> ast .FunctionDef | ast .AsyncFunctionDef :
62
+ def _process_function_def_common (self , node : ast .FunctionDef | ast .AsyncFunctionDef ) -> None :
61
63
self .context_stack .append (node .name )
62
64
i = len (node .body ) - 1
63
65
test_qualified_name = "." .join (self .context_stack )
@@ -83,7 +85,6 @@ def _process_function_def(
83
85
self .results [line_node .lineno ] = self .get_comment (match_key )
84
86
i -= 1
85
87
self .context_stack .pop ()
86
- return node
87
88
88
89
89
90
def get_fn_call_linenos (
0 commit comments