Skip to content

Commit

Permalink
google: raise an error for broken arguments (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed May 26, 2021
1 parent 6ab9239 commit 7ca3883
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docstring_parser/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ def _build_meta(self, text: str, title: str) -> DocstringMeta:
) or section.type == SectionType.SINGULAR:
return self._build_single_meta(section, text)

if ":" not in text:
raise ParseError("Expected a colon in {}.".format(repr(text)))

# Split spec and description
before, desc = text.split(":", 1)
if desc:
Expand Down
11 changes: 11 additions & 0 deletions docstring_parser/tests/test_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,14 @@ def test_unknown_meta() -> None:
assert docstring.params[0].description == "desc0"
assert docstring.params[1].arg_name == "arg1"
assert docstring.params[1].description == "desc1"


def test_broken_arguments() -> None:
with pytest.raises(ParseError):
docstring = parse(
"""This is a test
Args:
param - poorly formatted
"""
)

0 comments on commit 7ca3883

Please sign in to comment.