File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -263,17 +263,21 @@ def visit_Assign(self, node: ast.Assign) -> None:
263263 return
264264
265265 # Check if the assignment is a class instantiation
266- if isinstance (node .value , ast .Call ) and isinstance (node .value .func , ast .Name ):
266+ handled_assignment = False
267+ if isinstance (node .value , ast .Call ) and type (node .value .func ) is ast .Name :
267268 class_name = node .value .func .id
268269 if class_name in self .imported_modules :
269270 # Track all target variables as instances of the imported class
270271 for target in node .targets :
271- if isinstance (target , ast .Name ) :
272+ if type (target ) is ast .Name :
272273 # Map the variable to the actual class name (handling aliases)
273274 original_class = self .alias_mapping .get (class_name , class_name )
274275 self .instance_mapping [target .id ] = original_class
276+ handled_assignment = True
275277
276- self .generic_visit (node )
278+ # Only traverse child nodes if we didn't handle a class instantiation assignment
279+ if not handled_assignment :
280+ self .generic_visit (node )
277281
278282 def visit_ImportFrom (self , node : ast .ImportFrom ) -> None :
279283 """Handle 'from module import name' statements."""
You can’t perform that action at this time.
0 commit comments