Skip to content

Commit

Permalink
feat: Get attributes annotations from parent
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Nov 13, 2021
1 parent a9ed6e9 commit 003b990
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/griffe/docstrings/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _read_other_parameters_section(docstring: Docstring, offset: int) -> tuple[D
return None, index


def _read_attributes_section(docstring: Docstring, offset: int) -> tuple[DocstringSection | None, int]:
def _read_attributes_section(docstring: Docstring, offset: int) -> tuple[DocstringSection | None, int]: # noqa: WPS231
attributes = []
block, index = _read_block_items(docstring, offset)

Expand All @@ -225,7 +225,10 @@ def _read_attributes_section(docstring: Docstring, offset: int) -> tuple[Docstri
annotation = annotation[:-10]
else:
name = name_with_type
annotation = None
try:
annotation = docstring.parent.attributes[name].annotation # type: ignore
except (AttributeError, KeyError):
annotation = None

attributes.append(DocstringAttribute(name=name, annotation=annotation, description=description))

Expand Down

0 comments on commit 003b990

Please sign in to comment.