henry0312 / pytest-pydocstyle

pytest plugin to run pydocstyle
MIT License
14 stars 3 forks source link

IndentationError on test run instead of pass/fail #56

Closed kmantel closed 4 years ago

kmantel commented 4 years ago
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pluggy/manager.py:87: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/_pytest/runner.py:131: in pytest_runtest_call
    item.runtest()
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pytest_pydocstyle.py:72: in runtest
    ignore_decorators=ignore_decorators)]
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pytest_pydocstyle.py:71: in <listcomp>
    errors = [str(error) for error in pydocstyle.check((str(self.fspath),), select=checked_codes,
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pydocstyle/checker.py:969: in check
    ignore_decorators):
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pydocstyle/checker.py:123: in check_source
    for error in errors:
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pydocstyle/checker.py:917: in check_docstring_sections
    yield from self._check_google_sections(lines, definition, docstring)
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pydocstyle/checker.py:903: in _check_google_sections
    yield from self._check_google_section(docstring, definition, ctx)
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pydocstyle/checker.py:796: in _check_google_section
    yield from cls._check_args_section(docstring, definition, context)
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pydocstyle/checker.py:748: in _check_args_section
    yield from ConventionChecker._check_missing_args(docstring_args, definition)
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pydocstyle/checker.py:762: in _check_missing_args
    function_args = get_function_args(definition.source)
../../.pyenv/versions/pnl375/lib/python3.7/site-packages/pydocstyle/checker.py:1002: in get_function_args
    function_arg_node = ast.parse(textwrap.dedent(function_string)).body[0].args
../../.pyenv/versions/3.7.5/lib/python3.7/ast.py:35: in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
E     File "<unknown>", line 1
E       def bar(self):
E       ^
E   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

henry0312 commented 4 years ago

Thank you for your reporting, but it is the issue of pydocstyle, not pytest-docstyle. Can you open a issue in pydocstyle?