From 7ca3883daa08a6603a261e3b1ae0b1417350bede Mon Sep 17 00:00:00 2001 From: rr- Date: Wed, 26 May 2021 17:29:19 +0200 Subject: [PATCH] google: raise an error for broken arguments (#35) --- docstring_parser/google.py | 3 +++ docstring_parser/tests/test_google.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/docstring_parser/google.py b/docstring_parser/google.py index 4864393..4573dd7 100644 --- a/docstring_parser/google.py +++ b/docstring_parser/google.py @@ -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: diff --git a/docstring_parser/tests/test_google.py b/docstring_parser/tests/test_google.py index 5f71b9f..9c061fb 100644 --- a/docstring_parser/tests/test_google.py +++ b/docstring_parser/tests/test_google.py @@ -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 + """ + )