From a3dcabbdb98987da002c5f42a4c76270f9c9fbb8 Mon Sep 17 00:00:00 2001 From: "Mitchell T.H. Young" Date: Tue, 24 Apr 2018 07:23:49 -0700 Subject: Add support for numpydoc return value names (#2031) Numpydoc specification allows for optional return value name in the form of: ``` Returns ------- name : type Some description ``` These were not being honored by the current regex for return lines. This adds an optional, non-capturing group to the regex which accounts for the `name : ` bit. Fixes #2030 --- CONTRIBUTORS.txt | 2 ++ ChangeLog | 4 ++++ pylint/extensions/_check_docs_utils.py | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 40f0deb42..1ba25c7b4 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -162,3 +162,5 @@ Order doesn't matter (not that much, at least ;) * Tobias Hernstig: contributor * Jason Owen: contributor + +* Mitchell Young: minor adjustment to docparams diff --git a/ChangeLog b/ChangeLog index d372b303d..e53e250cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,10 @@ Release date: |TBA| Close #1867 + * Add support for nupmydoc optional return value names. + + Close #2030 + What's New in Pylint 1.9.3? =========================== diff --git a/pylint/extensions/_check_docs_utils.py b/pylint/extensions/_check_docs_utils.py index a995e15e2..594bd860e 100644 --- a/pylint/extensions/_check_docs_utils.py +++ b/pylint/extensions/_check_docs_utils.py @@ -694,8 +694,9 @@ class NumpyDocstring(GoogleDocstring): ) re_returns_line = re.compile(r""" - \s* ({type})$ # type declaration - \s* (.*) # optional description + \s* (?:\w+\s+:\s+)? # optional name + ({type})$ # type declaration + \s* (.*) # optional description """.format( type=GoogleDocstring.re_multiple_type, ), re.X | re.S | re.M) -- cgit v1.2.1