Skip to content

Commit 3249155

Browse files
committed
fix: Fix iterating non-flat expressions (some nodes were skipped)
1 parent 3821ccd commit 3249155

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/griffe/expressions.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class ExprCall(Expr):
235235
arguments: Sequence[str | Expr]
236236

237237
def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
238-
yield from self.function.iterate(flat=flat)
238+
yield from _yield(self.function, flat=flat)
239239
yield "("
240240
yield from _join(self.arguments, ", ", flat=flat)
241241
yield ")"
@@ -293,11 +293,12 @@ class ExprDict(Expr):
293293
keys: Sequence[str | Expr | None]
294294
values: Sequence[str | Expr]
295295

296-
def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: ARG002,D102
296+
def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
297297
yield "{"
298298
yield from _join(
299299
(("None" if key is None else key, ": ", value) for key, value in zip(self.keys, self.values)),
300300
", ",
301+
flat=flat,
301302
)
302303
yield "}"
303304

@@ -403,7 +404,7 @@ class ExprVarPositional(Expr):
403404

404405
def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
405406
yield "*"
406-
yield from self.value.iterate(flat=flat)
407+
yield from _yield(self.value, flat=flat)
407408

408409

409410
@dataclass(eq=True, **dataclass_opts)
@@ -414,7 +415,7 @@ class ExprVarKeyword(Expr):
414415

415416
def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
416417
yield "**"
417-
yield from self.value.iterate(flat=flat)
418+
yield from _yield(self.value, flat=flat)
418419

419420

420421
@dataclass(eq=True, **dataclass_opts)
@@ -520,7 +521,7 @@ class ExprNamedExpr(Expr):
520521

521522
def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
522523
yield "("
523-
yield from self.target.iterate(flat=flat)
524+
yield from _yield(self.target, flat=flat)
524525
yield " := "
525526
yield from _yield(self.value, flat=flat)
526527
yield ")"
@@ -590,7 +591,7 @@ class ExprSubscript(Expr):
590591
slice: Expr # noqa: A003
591592

592593
def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
593-
yield from self.left.iterate(flat=flat)
594+
yield from _yield(self.left, flat=flat)
594595
yield "["
595596
yield from _yield(self.slice, flat=flat)
596597
yield "]"

0 commit comments

Comments
 (0)