Skip to content

Commit 2d68a0d

Browse files
committed
Special case args and kwargs in numpy/google arg list
Note Astropy uses colon and type/optional annotation
1 parent 3e54ca7 commit 2d68a0d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

flake8_rst_docstrings.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,5 +257,38 @@ def run(self):
257257
code += 100 * rst_error.level
258258
msg = "%s%03i %s" % (rst_prefix, code, msg)
259259

260+
if code == 210:
261+
if "\nArgs:\n" in docstring and docstring.find(
262+
"\nArgs:\n"
263+
) < docstring.find(" **kwargs:"):
264+
# Ignore special case used in Google docstring style
265+
continue
266+
if "\nParameters\n----------\n" in docstring and docstring.find(
267+
"\nParameters\n----------\n"
268+
) < docstring.find("\n**kwargs\n"):
269+
# Ignore special case used in NumPy docstring style
270+
continue
271+
if "\nParameters\n----------\n" in docstring and docstring.find(
272+
"\nParameters\n----------\n"
273+
) < docstring.find("\n**kwargs :"):
274+
# Ignore special case used in NumPy docstring style
275+
continue
276+
elif code == 213:
277+
if "\nArgs:\n" in docstring and docstring.find(
278+
"\nArgs:\n"
279+
) < docstring.find(" *args:"):
280+
# Ignore special case used in Google docstring style
281+
continue
282+
if "\nParameters\n----------\n" in docstring and docstring.find(
283+
"\nParameters\n----------\n"
284+
) < docstring.find("\n*args\n"):
285+
# Ignore special case used in NumPy docstring style
286+
continue
287+
if "\nParameters\n----------\n" in docstring and docstring.find(
288+
"\nParameters\n----------\n"
289+
) < docstring.find("\n*args :"):
290+
# Ignore special case used in NumPy docstring style
291+
continue
292+
260293
# We don't know the column number, leaving as zero.
261294
yield start + rst_error.line, 0, msg, type(self)

0 commit comments

Comments
 (0)