jsh9 / pydoclint

A Python docstring linter that checks arguments, returns, yields, and raises sections
https://pypi.org/project/pydoclint/
MIT License
149 stars 15 forks source link

pydoclint failing with InternalError after upgrade from 0.4.2 -> 0.5.3 #151

Closed haakonvt closed 4 months ago

haakonvt commented 4 months ago

While trying to bump the version, pydoclint started failing in pre-commit: https://github.com/cognitedata/cognite-sdk-python/pull/1830

The full stack trace:

pydoclint................................................................Failed
- hook id: pydoclint
- exit code: 1

Loading config from user-specified .toml file: pyproject.toml
No config found in pyproject.toml.
Traceback (most recent call last):
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/bin/pydoclint", line 8, in <module>
    sys.exit(main())
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/lib/python3.8/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/lib/python3.8/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/lib/python3.8/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/lib/python3.8/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/lib/python3.8/site-packages/click/decorators.py", line [33](https://github.com/cognitedata/cognite-sdk-python/actions/runs/9873584003/job/27266161427#step:4:34), in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/lib/python3.8/site-packages/pydoclint/main.py", line [36](https://github.com/cognitedata/cognite-sdk-python/actions/runs/9873584003/job/27266161427#step:4:37)4, in main
    violationsInAllFiles: Dict[str, List[Violation]] = _checkPaths(
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/lib/python3.8/site-packages/pydoclint/main.py", line 527, in _checkPaths
    violationsInThisFile: List[Violation] = _checkFile(
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/lib/python3.8/site-packages/pydoclint/main.py", line 591, in _checkFile
    visitor.visit(tree)
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/ast.py", line [37](https://github.com/cognitedata/cognite-sdk-python/actions/runs/9873584003/job/27266161427#step:4:38)1, in visit
    return visitor(node)
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/ast.py", line 379, in generic_visit
    self.visit(item)
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/ast.py", line 371, in visit
    return visitor(node)
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/lib/python3.8/site-packages/pydoclint/visitor.py", line 91, in visit_ClassDef
    checkClassAttributesAgainstClassDocstring(
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/lib/python3.8/site-packages/pydoclint/utils/visitor_helper.py", line 42, in checkClassAttributesAgainstClassDocstring
    actualArgs: ArgList = _convertClassAttributesIntoArgList(classAttributes)
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/lib/python3.8/site-packages/pydoclint/utils/visitor_helper.py", line 1[40](https://github.com/cognitedata/cognite-sdk-python/actions/runs/9873584003/job/27266161427#step:4:41), in _convertClassAttributesIntoArgList
    atl.append(Arg.fromAstAssignWithNonTupleTarget(attr))
  File "/home/runner/.cache/pre-commit/repo1jglaof_/py_env-python3.8/lib/python3.8/site-packages/pydoclint/utils/arg.py", line 98, in fromAstAssignWithNonTupleTarget
    raise InternalError(
pydoclint.utils.internal_error.InternalError: astAssign.targets has length 4
jsh9 commented 4 months ago

Let me take a look.

jsh9 commented 4 months ago

Hi @haakonvt , I fixed this issue in version 0.5.5. Now your repo can pass pydoclint without any problems.