diff --git a/doc/whatsnew/2/2.14/full.rst b/doc/whatsnew/2/2.14/full.rst index edc5fa4c7e..e98432e115 100644 --- a/doc/whatsnew/2/2.14/full.rst +++ b/doc/whatsnew/2/2.14/full.rst @@ -17,6 +17,10 @@ Release date: TBA * Fixed the disabling of ``fixme`` and its interaction with ``useless-suppression``. +* Allow lists of default values in parameter documentation for ``Numpy`` style. + + Closes #4035 + What's New in Pylint 2.14.4? ---------------------------- diff --git a/pylint/extensions/_check_docs_utils.py b/pylint/extensions/_check_docs_utils.py index dacdbe05ee..d8bf22e228 100644 --- a/pylint/extensions/_check_docs_utils.py +++ b/pylint/extensions/_check_docs_utils.py @@ -727,11 +727,22 @@ class NumpyDocstring(GoogleDocstring): re.X | re.S | re.M, ) + re_default_value = r"""((['"]\w+\s*['"])|(True)|(False)|(None))""" + re_param_line = re.compile( rf""" - \s* (\*{{0,2}}\w+)(\s?(:|\n)) # identifier with potential asterisks - \s* (?:({GoogleDocstring.re_multiple_type})(?:,\s+optional)?\n)? # optional type declaration - \s* (.*) # optional description + \s* (\*{{0,2}}\w+)(\s?(:|\n)) # identifier with potential asterisks + \s* + ( + ( + ({GoogleDocstring.re_multiple_type}) # default type declaration + (,\s+optional)? # optional 'optional' indication + )? + ( + {{({re_default_value},?\s*)+}} # set of default values + )? + \n)? + \s* (.*) # optional description """, re.X | re.S, ) diff --git a/tests/functional/ext/docparams/parameter/missing_param_doc_required_Numpy.py b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Numpy.py index c47d03c316..6e725980fb 100644 --- a/tests/functional/ext/docparams/parameter/missing_param_doc_required_Numpy.py +++ b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Numpy.py @@ -391,3 +391,18 @@ def test_ignores_optional_specifier_numpy(param, param2="all"): Description. """ return param, param2 + +def test_with_list_of_default_values(arg, option, option2): + """Reported in https://github.com/PyCQA/pylint/issues/4035. + + Parameters + ---------- + arg : int + The number of times to print it. + option : {"y", "n"} + Do I do it? + option2 : {"y", None, "n"} + Do I do it? + + """ + return arg, option, option2