prospector-dev / prospector

Inspects Python source files and provides information about type and location of classes, methods etc
GNU General Public License v2.0
1.95k stars 171 forks source link

Pylint throws when used via prospector v1.8.3 via pre-commit hook #586

Closed ghost closed 1 year ago

ghost commented 1 year ago

Describe the bug I'm trying to use the prospector 1.8.3 via pre-commit hook, but some non-linting-related pylint error appears (if I run prospector manually without pre-commit - everything works as expected)

To Reproduce Steps to reproduce the behavior:

.prospector.yaml

max-line-length: 120
ignore-paths:
  - infra/io/csv_utils.py
pylint:
  options:
    extension-pkg-whitelist:
      - dependency_injector
  disable:
    - logging-fstring-interpolation

.pre-commit-config.yaml

repos:
-   repo: https://github.com/pycqa/isort
    rev: 5.12.0
    hooks:
    -   id: isort
        name: isort (python)
-   repo: https://github.com/psf/black
    rev: 22.12.0
    hooks:
    -   id: black
-   repo: https://github.com/PyCQA/prospector
    rev: v1.8.3
    hooks:
    -   id: prospector

Call prospector the following way pre-commit run --all-files Output:

isort (python)...........................................................Passed
black....................................................................Passed
prospector...............................................................Failed
- hook id: prospector
- exit code: 1

Messages
========

.
  Line: None
    pylint: failure / Tool pylint failed to run (exception was raised, re-run prospector with -X to see the stacktrace)

inference/algorithm/supply.py
  Line: 347
    pycodestyle: E501 / line too long (286 > 120 characters) (col 121)

After adding -X to prospector params (as the error message suggests) I receive this:

Error message with -X passed ``` pre-commit run --all-files isort (python)...........................................................Passed black....................................................................Passed prospector...............................................................Failed - hook id: prospector - exit code: 1 Traceback (most recent call last): File "/Users/user/.cache/pre-commit/repod28udnss/py_env-python3.8/lib/python3.8/site-packages/prospector/run.py", line 87, in execute messages += tool.run(found_files) File "/Users/user/.cache/pre-commit/repod28udnss/py_env-python3.8/lib/python3.8/site-packages/prospector/tools/pylint/__init__.py", line 239, in run self._linter.check(self._args) File "/Users/user/.cache/pre-commit/repod28udnss/py_env-python3.8/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 696, in check ast_per_fileitem = self._get_asts(fileitems, data) File "/Users/user/.cache/pre-commit/repod28udnss/py_env-python3.8/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 707, in _get_asts for fileitem in fileitems: File "/Users/user/.cache/pre-commit/repod28udnss/py_env-python3.8/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 874, in _iterate_file_descrs for descr in self._expand_files(files_or_modules).values(): File "/Users/user/.cache/pre-commit/repod28udnss/py_env-python3.8/lib/python3.8/site-packages/prospector/tools/pylint/linter.py", line 36, in _expand_files if not self._files.is_excluded(Path(module["path"])): TypeError: string indices must be integers The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/user/.cache/pre-commit/repod28udnss/py_env-python3.8/bin/prospector", line 8, in sys.exit(main()) File "/Users/user/.cache/pre-commit/repod28udnss/py_env-python3.8/lib/python3.8/site-packages/prospector/run.py", line 199, in main prospector.execute() File "/Users/user/.cache/pre-commit/repod28udnss/py_env-python3.8/lib/python3.8/site-packages/prospector/run.py", line 105, in execute raise FatalProspectorException(f"Tool {toolname} failed to run.") from ex prospector.exceptions.FatalProspectorException: Tool pylint failed to run. ```

Expected behavior I expect prospector to run and warn only about linting-related issues

Environment (please complete the following information):

Additional context pre-commit 3.0.2

Pierre-Sassoulas commented 1 year ago

Can you confirm the problem also exists with prospector 1.8.4 ?

ghost commented 1 year ago

@Pierre-Sassoulas This particular one no, but with 1.8.4 I face this one #587

Pierre-Sassoulas commented 1 year ago

I'm going to close in favor of #587 then.