summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell T.H. Young <mitchelly@gmail.com>2018-04-24 07:23:49 -0700
committerAshley Whetter <asw@dneg.com>2018-07-26 11:43:08 -0700
commita3dcabbdb98987da002c5f42a4c76270f9c9fbb8 (patch)
tree909d633b1e88028a4029d8016a3677f2946f03ee
parent1fa16ab6251953b9f4ae9493b4533e84c78cdff6 (diff)
downloadpylint-git-a3dcabbdb98987da002c5f42a4c76270f9c9fbb8.tar.gz
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
-rw-r--r--CONTRIBUTORS.txt2
-rw-r--r--ChangeLog4
-rw-r--r--pylint/extensions/_check_docs_utils.py5
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)