Skip to content

Commit c05805b

Browse files
committed
Refactor for less nesting
1 parent 4324c89 commit c05805b

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

flake8_rst_docstrings.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -256,36 +256,39 @@ def run(self):
256256
code += 100 * rst_error.level
257257
msg = "%s%03i %s" % (rst_prefix, code, msg)
258258

259-
if code == 210:
260-
if "\nArgs:\n" in docstring and docstring.find(
261-
"\nArgs:\n"
262-
) < docstring.find(" **kwargs:"):
263-
# Ignore special case used in Google docstring style
264-
continue
265-
if "\nParameters\n----------\n" in docstring and docstring.find(
259+
if (
260+
code == 210
261+
and "\nArgs:\n" in docstring
262+
and docstring.find("\nArgs:\n")
263+
< docstring.find(" **kwargs:")
264+
):
265+
# Ignore special case used in Google docstring style
266+
continue
267+
elif code == 210 and "\nParameters\n----------\n" in docstring:
268+
if docstring.find(
266269
"\nParameters\n----------\n"
267-
) < docstring.find("\n**kwargs\n"):
268-
# Ignore special case used in NumPy docstring style
269-
continue
270-
if "\nParameters\n----------\n" in docstring and docstring.find(
270+
) < docstring.find("\n**kwargs\n") or docstring.find(
271271
"\nParameters\n----------\n"
272-
) < docstring.find("\n**kwargs :"):
272+
) < docstring.find(
273+
"\n**kwargs :"
274+
):
273275
# Ignore special case used in NumPy docstring style
274276
continue
275-
elif code == 213:
276-
if "\nArgs:\n" in docstring and docstring.find(
277-
"\nArgs:\n"
278-
) < docstring.find(" *args:"):
279-
# Ignore special case used in Google docstring style
280-
continue
281-
if "\nParameters\n----------\n" in docstring and docstring.find(
277+
elif (
278+
code == 213
279+
and "\nArgs:\n" in docstring
280+
and docstring.find("\nArgs:\n") < docstring.find(" *args:")
281+
):
282+
# Ignore special case used in Google docstring style
283+
continue
284+
elif code == 213 and "\nParameters\n----------\n" in docstring:
285+
if docstring.find(
282286
"\nParameters\n----------\n"
283-
) < docstring.find("\n*args\n"):
284-
# Ignore special case used in NumPy docstring style
285-
continue
286-
if "\nParameters\n----------\n" in docstring and docstring.find(
287+
) < docstring.find("\n*args\n") or docstring.find(
287288
"\nParameters\n----------\n"
288-
) < docstring.find("\n*args :"):
289+
) < docstring.find(
290+
"\n*args :"
291+
):
289292
# Ignore special case used in NumPy docstring style
290293
continue
291294

0 commit comments

Comments
 (0)