File tree 1 file changed +5
-12
lines changed
1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -200,19 +200,12 @@ def __init_subclass__(cls) -> None:
200
200
201
201
def get_visit_fn (self , kind : str , is_leaving : bool = False ) -> Callable :
202
202
"""Get the visit function for the given node kind and direction."""
203
-
204
203
key = (kind , is_leaving )
205
- if key in self ._visit_fns :
206
- return self ._visit_fns [key ]
207
-
208
- method = "leave" if is_leaving else "enter"
209
- visit_fn = getattr (self , f"{ method } _{ kind } " , None )
210
- if not visit_fn :
211
- visit_fn = getattr (self , method , None )
212
-
213
- self ._visit_fns [key ] = visit_fn
214
-
215
- return visit_fn
204
+ if key not in self ._visit_fns :
205
+ method = "leave" if is_leaving else "enter"
206
+ fn = getattr (self , f"{ method } _{ kind } " , None )
207
+ self ._visit_fns [key ] = fn or getattr (self , method , None )
208
+ return self ._visit_fns [key ]
216
209
217
210
218
211
class Stack (NamedTuple ):
You can’t perform that action at this time.
0 commit comments