@@ -152,20 +152,20 @@ def parse_classdef(self, node, data=None):
152
152
continue
153
153
154
154
for child in base .get_children ():
155
- name = getattr (child , "name" , None )
156
- if isinstance (child , (astroid .Assign , astroid .AnnAssign )):
157
- assign_value = _astroid_utils .get_assign_value (child )
158
- if not assign_value :
155
+ children_data = self .parse (child )
156
+ for child_data in children_data :
157
+ name = child_data ["name" ]
158
+
159
+ existing_child = children .get (name )
160
+ if existing_child and not existing_child ["doc" ]:
161
+ existing_child ["doc" ] = child_data ["doc" ]
162
+
163
+ if name in overridden :
159
164
continue
160
- name = assign_value [0 ]
161
165
162
- if not name or name in overridden :
163
- continue
164
- seen .add (name )
165
- child_data = self .parse (child )
166
- base_children .extend (
167
- _parse_child (node , child_data , overloads , base , name )
168
- )
166
+ seen .add (name )
167
+ if _parse_child (node , child_data , overloads , base ):
168
+ base_children .append (child_data )
169
169
170
170
overridden .update (seen )
171
171
@@ -297,11 +297,13 @@ def parse_module(self, node):
297
297
top_name = node .name .split ("." , 1 )[0 ]
298
298
for child in node .get_children ():
299
299
if _astroid_utils .is_local_import_from (child , top_name ):
300
- child_data = self ._parse_local_import_from (child )
300
+ children_data = self ._parse_local_import_from (child )
301
301
else :
302
- child_data = self .parse (child )
302
+ children_data = self .parse (child )
303
303
304
- data ["children" ].extend (_parse_child (node , child_data , overloads ))
304
+ for child_data in children_data :
305
+ if _parse_child (node , child_data , overloads ):
306
+ data ["children" ].append (child_data )
305
307
306
308
return data
307
309
@@ -346,28 +348,28 @@ def parse(self, node):
346
348
data = self .parse (child )
347
349
if data :
348
350
break
351
+
349
352
return data
350
353
351
354
352
- def _parse_child (node , child_data , overloads , base = None , name = None ) :
353
- result = []
354
- for single_data in child_data :
355
- if single_data [ "type" ] in ( "function" , "method" , "property" ) :
356
- if name is None :
357
- name = single_data [ "name " ]
358
- if name in overloads :
359
- grouped = overloads [ name ]
360
- grouped ["doc" ] = single_data [ "doc" ]
361
- if single_data [ "is_overload" ]:
362
- grouped [ "overloads" ]. append (
363
- ( single_data [ "args" ], single_data [ "return_annotation" ])
364
- )
365
- continue
366
- if single_data ["is_overload" ] and name not in overloads :
367
- overloads [name ] = single_data
355
+ def _parse_child (node , child_data , overloads , base = None ) -> bool :
356
+ if child_data [ "type" ] in ( "function" , "method" , "property" ):
357
+ name = child_data [ "name" ]
358
+ if name in overloads :
359
+ grouped = overloads [ name ]
360
+ grouped [ "doc" ] = child_data [ "doc " ]
361
+
362
+ if child_data [ "is_overload" ]:
363
+ grouped ["overloads" ]. append (
364
+ ( child_data [ "args" ], child_data [ "return_annotation" ])
365
+ )
366
+
367
+ return False
368
+
369
+ if child_data ["is_overload" ] and name not in overloads :
370
+ overloads [name ] = child_data
368
371
369
- if base :
370
- single_data ["inherited" ] = base is not node
371
- result .append (single_data )
372
+ if base :
373
+ child_data ["inherited" ] = base is not node
372
374
373
- return result
375
+ return True
0 commit comments