Skip to content

Commit 228e34d

Browse files
committed
Corrected child order
52e6765 introduced a new type of child iteration. Some classes started yielding children in the incorrect order, which was causing test failures in pylint. This change corrects the ordering to match the _astroid_fields of the class. Relates to a change from #497
1 parent dfbbeaa commit 228e34d

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

astroid/node_classes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,12 +1539,6 @@ def get_children(self):
15391539
yield from self.defaults
15401540
yield from self.kwonlyargs
15411541

1542-
if self.varargannotation is not None:
1543-
yield self.varargannotation
1544-
1545-
if self.kwargannotation is not None:
1546-
yield self.kwargannotation
1547-
15481542
for elt in self.kw_defaults:
15491543
if elt is not None:
15501544
yield elt
@@ -1553,6 +1547,12 @@ def get_children(self):
15531547
if elt is not None:
15541548
yield elt
15551549

1550+
if self.varargannotation is not None:
1551+
yield self.varargannotation
1552+
1553+
if self.kwargannotation is not None:
1554+
yield self.kwargannotation
1555+
15561556
for elt in self.kwonlyargs_annotations:
15571557
if elt is not None:
15581558
yield elt
@@ -3770,12 +3770,12 @@ def get_children(self):
37703770
if self.lower is not None:
37713771
yield self.lower
37723772

3773-
if self.step is not None:
3774-
yield self.step
3775-
37763773
if self.upper is not None:
37773774
yield self.upper
37783775

3776+
if self.step is not None:
3777+
yield self.step
3778+
37793779

37803780
class Starred(mixins.ParentAssignTypeMixin, NodeNG):
37813781
"""Class representing an :class:`ast.Starred` node.

astroid/scoped_nodes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,14 +2694,14 @@ def bool_value(self):
26942694
return True
26952695

26962696
def get_children(self):
2697-
for elt in self.body:
2698-
yield elt
2697+
if self.decorators is not None:
2698+
yield self.decorators
26992699

27002700
for elt in self.bases:
27012701
yield elt
27022702

2703-
if self.decorators is not None:
2704-
yield self.decorators
2703+
for elt in self.body:
2704+
yield elt
27052705

27062706
def _get_assign_nodes(self):
27072707
for child_node in self.body:

0 commit comments

Comments
 (0)