@@ -153,7 +153,7 @@ def visit(stmt: ast.stmt, live_out: Set[str]) -> Set[str]:
153153 return live
154154
155155 def do_visit (stmt : ast .stmt , live_out : Set [str ]) -> Set [str ]:
156- def visitBlock (block : Sequence [ast .stmt ], live_out : Set [str ]) -> Set [str ]:
156+ def visit_block (block : Sequence [ast .stmt ], live_out : Set [str ]) -> Set [str ]:
157157 for s in reversed (block ):
158158 live_out = visit (s , live_out )
159159 return live_out
@@ -167,28 +167,28 @@ def visitBlock(block: Sequence[ast.stmt], live_out: Set[str]) -> Set[str]:
167167 if isinstance (stmt , ast .If ):
168168 constant_cond = self .constant_if_condition (stmt )
169169 if constant_cond is None :
170- live1 = visitBlock (stmt .body , live_out )
171- live2 = visitBlock (stmt .orelse , live_out )
170+ live1 = visit_block (stmt .body , live_out )
171+ live2 = visit_block (stmt .orelse , live_out )
172172 return live1 | live2 | _used_vars (stmt .test )
173173 elif constant_cond :
174- return visitBlock (stmt .body , live_out )
174+ return visit_block (stmt .body , live_out )
175175 else :
176- return visitBlock (stmt .orelse , live_out )
176+ return visit_block (stmt .orelse , live_out )
177177 if isinstance (stmt , ast .For ):
178178 p_loop_var = _get_loop_var (stmt , self ._formatter )
179179 prev = None
180180 curr = live_out
181181 while curr != prev :
182182 prev = curr
183- curr = visitBlock (stmt .body , prev ).difference ({p_loop_var })
183+ curr = visit_block (stmt .body , prev ).difference ({p_loop_var })
184184 return curr
185185 if isinstance (stmt , ast .While ):
186186 cond_vars = _used_vars (stmt .test )
187187 prev = None
188188 curr = live_out | cond_vars
189189 while curr != prev :
190190 prev = curr
191- curr = visitBlock (stmt .body , prev ) | cond_vars
191+ curr = visit_block (stmt .body , prev ) | cond_vars
192192 return curr
193193 if isinstance (stmt , ast .Break ):
194194 # The following is sufficient for the current restricted usage, where
@@ -228,7 +228,7 @@ def exposed_uses(self, stmts: Sequence[ast.stmt]) -> set[str]:
228228 (in the first statement). Hence x is included in the exposed_uses.
229229 """
230230
231- def visitBlock (block : Sequence [ast .stmt ], live_out : Set [str ]) -> Set [str ]:
231+ def visit_block (block : Sequence [ast .stmt ], live_out : Set [str ]) -> Set [str ]:
232232 for stmt in reversed (block ):
233233 live_out = visit (stmt , live_out )
234234 return live_out
@@ -243,13 +243,13 @@ def visit(stmt: ast.stmt, live_out: Set[str]) -> Set[str]:
243243 if isinstance (stmt , ast .If ):
244244 constant_cond = self .constant_if_condition (stmt )
245245 if constant_cond is None :
246- live1 = visitBlock (stmt .body , live_out )
247- live2 = visitBlock (stmt .orelse , live_out )
246+ live1 = visit_block (stmt .body , live_out )
247+ live2 = visit_block (stmt .orelse , live_out )
248248 return (live1 | live2 ) | _used_vars (stmt .test )
249249 elif constant_cond :
250- return visitBlock (stmt .body , live_out )
250+ return visit_block (stmt .body , live_out )
251251 else :
252- return visitBlock (stmt .orelse , live_out )
252+ return visit_block (stmt .orelse , live_out )
253253 if ast_utils .is_print_call (stmt ):
254254 return live_out
255255 if ast_utils .is_doc_string (stmt ):
@@ -259,13 +259,13 @@ def visit(stmt: ast.stmt, live_out: Set[str]) -> Set[str]:
259259 # for loops that execute at least once.
260260 loop_var_set = {_get_loop_var (stmt , self ._formatter )}
261261 used_after_loop = live_out .difference (loop_var_set )
262- used_inside_loop = visitBlock (stmt .body , set ()).difference (loop_var_set )
262+ used_inside_loop = visit_block (stmt .body , set ()).difference (loop_var_set )
263263 used_in_loop_header = _used_vars (stmt .iter )
264264 return used_inside_loop | used_in_loop_header | used_after_loop
265265 if isinstance (stmt , ast .While ):
266266 # Analysis assumes loop may execute zero times. Results can be improved
267267 # for loops that execute at least once.
268- used_inside_loop = visitBlock (stmt .body , set ())
268+ used_inside_loop = visit_block (stmt .body , set ())
269269 used_in_loop_header = _used_vars (stmt .test )
270270 return used_inside_loop | used_in_loop_header | live_out
271271 if isinstance (stmt , ast .Break ):
@@ -281,7 +281,7 @@ def visit(stmt: ast.stmt, live_out: Set[str]) -> Set[str]:
281281 self ._formatter (stmt , f"Unsupported statement type { type (stmt )!r} ." )
282282 )
283283
284- return visitBlock (stmts , set ())
284+ return visit_block (stmts , set ())
285285
286286 def outer_scope_variables (self , fun : ast .FunctionDef ) -> set [str ]:
287287 """Return the set of outer-scope variables used in a nested function.
0 commit comments