Skip to content

Commit

Permalink
fix: Fix getting arguments defaults in the Google-style parser
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Sep 28, 2021
1 parent 8bcbfba commit 67adbaf
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 @@ -184,8 +184,6 @@ def read_arguments(docstring: Docstring, start_index: int) -> tuple[list[Docstri
warn(docstring, index, f"Failed to get 'name: description' pair from '{arg_line}'")
continue

# setting defaults
default = None
description = description.lstrip()

# use the type given after the argument name, if any
Expand All @@ -202,6 +200,11 @@ def read_arguments(docstring: Docstring, start_index: int) -> tuple[list[Docstri
except (AttributeError, KeyError):
annotation = None

try:
default = docstring.parent.arguments[name].default # type: ignore
except (AttributeError, KeyError):
default = None

if annotation is None:
warn(docstring, index, f"No type or annotation for argument '{name}'")

Expand Down

0 comments on commit 67adbaf

Please sign in to comment.