@@ -205,11 +205,12 @@ def visit_Attribute(self, node: ast.Attribute) -> None:
205205 ]
206206 symbols = self ._current_symbols ()
207207 parent = self ._current_scope_parent ()
208+ final_component = cumulative_components [- 1 ]
208209 for cumulative_component in cumulative_components :
209210 qualifications = symbols .get (cumulative_component )
210211 if qualifications :
211212 for qualification in qualifications :
212- definition = RawDefinition (
213+ origin_definition = RawDefinition (
213214 name = qualification ,
214215 change_type = self .context_type .value ,
215216 line = node .lineno ,
@@ -218,7 +219,21 @@ def visit_Attribute(self, node: ast.Attribute) -> None:
218219 end_offset = node .end_col_offset ,
219220 parent = parent ,
220221 )
221- self .definitions .append (definition )
222+ # Replace prefix with qualification in final_component
223+ name = final_component .replace (
224+ cumulative_component , qualification , 1
225+ )
226+ definition = RawDefinition (
227+ name = name ,
228+ change_type = self .context_type .value ,
229+ line = node .lineno ,
230+ offset = node .col_offset ,
231+ end_line = node .end_lineno ,
232+ end_offset = node .end_col_offset ,
233+ parent = parent ,
234+ )
235+
236+ self .definitions .extend ([origin_definition , definition ])
222237
223238 def reset (self ):
224239 self .scope = []
0 commit comments