Skip to content

Commit 1b82319

Browse files
DanielNoordPierre-Sassoulas
authored andcommitted
Allow lists of default values in parameter documentation for Numpy (#7149)
1 parent 8af7472 commit 1b82319

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

doc/whatsnew/2/2.14/full.rst

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Release date: TBA
1717

1818
* Fixed the disabling of ``fixme`` and its interaction with ``useless-suppression``.
1919

20+
* Allow lists of default values in parameter documentation for ``Numpy`` style.
21+
22+
Closes #4035
23+
2024

2125
What's New in Pylint 2.14.4?
2226
----------------------------

pylint/extensions/_check_docs_utils.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -727,11 +727,22 @@ class NumpyDocstring(GoogleDocstring):
727727
re.X | re.S | re.M,
728728
)
729729

730+
re_default_value = r"""((['"]\w+\s*['"])|(True)|(False)|(None))"""
731+
730732
re_param_line = re.compile(
731733
rf"""
732-
\s* (\*{{0,2}}\w+)(\s?(:|\n)) # identifier with potential asterisks
733-
\s* (?:({GoogleDocstring.re_multiple_type})(?:,\s+optional)?\n)? # optional type declaration
734-
\s* (.*) # optional description
734+
\s* (\*{{0,2}}\w+)(\s?(:|\n)) # identifier with potential asterisks
735+
\s*
736+
(
737+
(
738+
({GoogleDocstring.re_multiple_type}) # default type declaration
739+
(,\s+optional)? # optional 'optional' indication
740+
)?
741+
(
742+
{{({re_default_value},?\s*)+}} # set of default values
743+
)?
744+
\n)?
745+
\s* (.*) # optional description
735746
""",
736747
re.X | re.S,
737748
)

tests/functional/ext/docparams/parameter/missing_param_doc_required_Numpy.py

+15
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,18 @@ def test_ignores_optional_specifier_numpy(param, param2="all"):
391391
Description.
392392
"""
393393
return param, param2
394+
395+
def test_with_list_of_default_values(arg, option, option2):
396+
"""Reported in https://github.com/PyCQA/pylint/issues/4035.
397+
398+
Parameters
399+
----------
400+
arg : int
401+
The number of times to print it.
402+
option : {"y", "n"}
403+
Do I do it?
404+
option2 : {"y", None, "n"}
405+
Do I do it?
406+
407+
"""
408+
return arg, option, option2

0 commit comments

Comments
 (0)