Skip to content

Commit

Permalink
fix: Don't crash on invalid signature given "Receives" section
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Sep 12, 2024
1 parent ef8324e commit 1cb8f51
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/_griffe/docstrings/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,8 @@ def _read_yields_section(
else:
# try to retrieve the annotation from the docstring parent
with suppress(AttributeError, IndexError, KeyError, ValueError):
annotation = docstring.parent.annotation # type: ignore[union-attr]
annotation = _maybe_destructure_annotation(
_unpack_generators(annotation, 0, mandatory=True),
_unpack_generators(docstring.parent.annotation, 0, mandatory=True), # type: ignore[union-attr]
index,
multiple=returns_multiple_items,
)
Expand Down Expand Up @@ -650,10 +649,9 @@ def _read_receives_section(
annotation = parse_docstring_annotation(annotation, docstring)
else:
# try to retrieve the annotation from the docstring parent
with suppress(AttributeError, KeyError):
annotation = docstring.parent.returns # type: ignore[union-attr]
with suppress(AttributeError, IndexError, KeyError, ValueError):
annotation = _maybe_destructure_annotation(
_unpack_generators(annotation, 1, mandatory=True),
_unpack_generators(docstring.parent.returns, 1, mandatory=True), # type: ignore[union-attr]
index,
multiple=receives_multiple_items,
)
Expand Down

0 comments on commit 1cb8f51

Please sign in to comment.