From 1cb8f514eae9d588cfce8cbbfc3ef84d7deadb47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Thu, 12 Sep 2024 11:55:55 +0200 Subject: [PATCH] fix: Don't crash on invalid signature given "Receives" section --- src/_griffe/docstrings/google.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/_griffe/docstrings/google.py b/src/_griffe/docstrings/google.py index 40680e22..cd228f85 100644 --- a/src/_griffe/docstrings/google.py +++ b/src/_griffe/docstrings/google.py @@ -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, ) @@ -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, )