Closed anntzer closed 4 years ago
Sorry if it's redundant but here's some additional info I mistakenly attributed to another module:
Traceback (most recent call last):
File "~/.pyenv/versions/pnl368/bin/pydocstyle", line 8, in <module>
sys.exit(main())
File "~/.pyenv/versions/3.6.8/envs/pnl368/lib/python3.6/site-packages/pydocstyle/cli.py", line 68, in main
sys.exit(run_pydocstyle())
File "~/.pyenv/versions/3.6.8/envs/pnl368/lib/python3.6/site-packages/pydocstyle/cli.py", line 45, in run_pydocstyle
ignore_decorators=ignore_decorators))
File "~/.pyenv/versions/3.6.8/envs/pnl368/lib/python3.6/site-packages/pydocstyle/checker.py", line 969, in check
ignore_decorators):
File "~/.pyenv/versions/3.6.8/envs/pnl368/lib/python3.6/site-packages/pydocstyle/checker.py", line 123, in check_source
for error in errors:
File "~/.pyenv/versions/3.6.8/envs/pnl368/lib/python3.6/site-packages/pydocstyle/checker.py", line 917, in check_docstring_sections
yield from self._check_google_sections(lines, definition, docstring)
File "~/.pyenv/versions/3.6.8/envs/pnl368/lib/python3.6/site-packages/pydocstyle/checker.py", line 903, in _check_google_sections
yield from self._check_google_section(docstring, definition, ctx)
File "~/.pyenv/versions/3.6.8/envs/pnl368/lib/python3.6/site-packages/pydocstyle/checker.py", line 796, in _check_google_section
yield from cls._check_args_section(docstring, definition, context)
File "~/.pyenv/versions/3.6.8/envs/pnl368/lib/python3.6/site-packages/pydocstyle/checker.py", line 748, in _check_args_section
yield from ConventionChecker._check_missing_args(docstring_args, definition)
File "~/.pyenv/versions/3.6.8/envs/pnl368/lib/python3.6/site-packages/pydocstyle/checker.py", line 762, in _check_missing_args
function_args = get_function_args(definition.source)
File "~/.pyenv/versions/3.6.8/envs/pnl368/lib/python3.6/site-packages/pydocstyle/checker.py", line 1002, in get_function_args
function_arg_node = ast.parse(textwrap.dedent(function_string)).body[0].args
File "~/.pyenv/versions/3.6.8/lib/python3.6/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
def bar(self):
^
IndentationError: unexpected indent
You can replicate it with a file containing
class Foo:
def bar(self):
'''
Arguments
---------
'''
# a
# b
pass
and you can avoid the error with several varying changes, like matching the indent of # b
to # a
, changing Arguments
to something else (except Args
), or removing the newlines in the docstring, which would then produce the expected docstyle error of D300: Use """triple double quotes""" (found '''-quotes)
So the error happens because the docstrings are not indented properly. As a result textwrap.dedent can dedent
the string. I am trying to look for a clean fix.
Shoudl be fixed by #441
as of pydocstyle 5.0.1:
analyzing with --convention=numpy results in