Skip to content

Commit

Permalink
feat: Support Google raises annotations cross-refs
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jan 14, 2022
1 parent 288803a commit 8006ae1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/griffe/docstrings/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ def _read_raises_section(docstring: Docstring, offset: int) -> tuple[DocstringSe
_warn(docstring, line_number, f"Failed to get 'exception: description' pair from '{exception_lines[0]}'")
else:
description = "\n".join([description.lstrip(), *exception_lines[1:]]).rstrip("\n")
# try to compile the annotation to transform it into an expression
with suppress(AttributeError, SyntaxError):
code = compile(annotation, mode="eval", filename="", flags=PyCF_ONLY_AST, optimize=2)
annotation = code.body and get_annotation(code.body, parent=docstring.parent) # type: ignore[assignment,arg-type]
exceptions.append(DocstringRaise(annotation=annotation, description=description))

if exceptions:
Expand Down

0 comments on commit 8006ae1

Please # to comment.