From 55bb868abc1fdd880a3749cfcb2eb4740be2bea5 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Wed, 17 Jul 2024 11:39:33 -0700 Subject: [PATCH 1/2] GL01 catches valid docstring example ``` def my_func(): """Docstring on first line. Should be totally fine. """ ... ``` --- numpydoc/validate.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/numpydoc/validate.py b/numpydoc/validate.py index 235841ea..2c8c9253 100644 --- a/numpydoc/validate.py +++ b/numpydoc/validate.py @@ -44,9 +44,8 @@ # modify/remove # start-err-msg ERROR_MSGS = { - "GL01": "Docstring text (summary) should start in the line immediately " - "after the opening quotes (not in the same line, or leaving a " - "blank line in between)", + "GL01": "Docstring text (summary) should start right after, or on the " + "line following the opening quotes", "GL02": "Closing quotes should be placed in the line after the last text " "in the docstring (do not close the quotes in the same line as " "the text, or leave a blank line between the last text and the " @@ -347,6 +346,7 @@ def start_blank_lines(self): for i, row in enumerate(self.raw_doc.split("\n")): if row.strip(): break + return i @property @@ -708,7 +708,7 @@ def validate(obj_name, validator_cls=None, **validator_kwargs): "examples_errors": "", } - if doc.start_blank_lines != 1 and "\n" in doc.raw_doc: + if doc.start_blank_lines not in (0, 1) and "\n" in doc.raw_doc: errs.append(error("GL01")) if doc.end_blank_lines != 1 and "\n" in doc.raw_doc: errs.append(error("GL02")) From 8895cefd388c7272eec648b1c88729fe0bbcf31a Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Fri, 22 May 2026 17:08:54 -0700 Subject: [PATCH 2/2] We allow summary on first line, directly after quote, as per the standard --- numpydoc/tests/test_validate.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py index f3be498b..910c1a1d 100644 --- a/numpydoc/tests/test_validate.py +++ b/numpydoc/tests/test_validate.py @@ -1576,10 +1576,7 @@ def test_bad_generic_functions(self, capsys, func): ( "BadSummaries", "wrong_line", - ( - "should start in the line immediately after the opening quotes", - "should be placed in the line after the last text", - ), + ("should be placed in the line after the last text",), ), ("BadSummaries", "no_punctuation", ("Summary does not end with a period",)), (