From 9aa41232f6553a63e1a6af136d2976cc9c22f6d6 Mon Sep 17 00:00:00 2001 From: Peter Cock Date: Thu, 2 Apr 2020 23:45:42 +0100 Subject: [PATCH] Special case args and kwargs in numpy/google arg list --- flake8_rst_docstrings.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/flake8_rst_docstrings.py b/flake8_rst_docstrings.py index a43472e..a0d2137 100644 --- a/flake8_rst_docstrings.py +++ b/flake8_rst_docstrings.py @@ -1090,6 +1090,28 @@ def run(self): assert 0 < code < 100, code code += 100 * rst_error.level msg = "%s%03i %s" % (rst_prefix, code, msg) + if code == 213: + if "\nArgs:\n" in unindented and unindented.find( + "\nArgs:\n" + ) < unindented.find(" *args:"): + # Ignore special case used in Google docstring style + continue + if "\nParameters\n----------\n" in unindented and unindented.find( + "\nParameters\n----------\n" + ) < unindented.find("\n*args\n"): + # Ignore special case used in NumPy docstring style + continue + if code == 210: + if "\nArgs:\n" in unindented and unindented.find( + "\nArgs:\n" + ) < unindented.find(" **kwargs:"): + # Ignore special case used in Google docstring style + continue + if "\nParameters\n----------\n" in unindented and unindented.find( + "\nParameters\n----------\n" + ) < unindented.find("\n**kwargs\n"): + # Ignore special case used in NumPy docstring style + continue # This will return the line number by combining the # start of the docstring with the offet within it.