Skip to content

Commit 1cb8f51

Browse files
committed
fix: Don't crash on invalid signature given "Receives" section
1 parent ef8324e commit 1cb8f51

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/_griffe/docstrings/google.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,8 @@ def _read_yields_section(
601601
else:
602602
# try to retrieve the annotation from the docstring parent
603603
with suppress(AttributeError, IndexError, KeyError, ValueError):
604-
annotation = docstring.parent.annotation # type: ignore[union-attr]
605604
annotation = _maybe_destructure_annotation(
606-
_unpack_generators(annotation, 0, mandatory=True),
605+
_unpack_generators(docstring.parent.annotation, 0, mandatory=True), # type: ignore[union-attr]
607606
index,
608607
multiple=returns_multiple_items,
609608
)
@@ -650,10 +649,9 @@ def _read_receives_section(
650649
annotation = parse_docstring_annotation(annotation, docstring)
651650
else:
652651
# try to retrieve the annotation from the docstring parent
653-
with suppress(AttributeError, KeyError):
654-
annotation = docstring.parent.returns # type: ignore[union-attr]
652+
with suppress(AttributeError, IndexError, KeyError, ValueError):
655653
annotation = _maybe_destructure_annotation(
656-
_unpack_generators(annotation, 1, mandatory=True),
654+
_unpack_generators(docstring.parent.returns, 1, mandatory=True), # type: ignore[union-attr]
657655
index,
658656
multiple=receives_multiple_items,
659657
)

0 commit comments

Comments
 (0)