econchick / interrogate

Explain yourself! Interrogate a codebase for docstring coverage.
https://interrogate.readthedocs.io
MIT License
562 stars 46 forks source link

Pre-commit hook #162

Closed ericmjl closed 3 months ago

ericmjl commented 8 months ago

Environment

Description of the bug

When running pre-commit with interrogate as one of the hooks, the interrogate hook fails with a ModuleNotFoundError for pkg_resources.

The traceback ends with:

ModuleNotFoundError: No module named 'pkg_resources'

What you expected to happen

interrogate should execute successfully when invoked as a hook in pre-commit, without any module import errors.

How to reproduce (as minimally and precisely as possible)

  1. Use Python version 3.12.0 for your virtual environment.
  2. Install pre-commit with a .pre-commit-config.yaml that includes interrogate as one of the hooks.
  3. Run pre-commit run --all-files.

The error occurs during the interrogate hook.

Anything else we need to know?

The issue seems to stem from a couple of interrelated issues:

  1. pre-commit defaults to using the latest Python version available, which, as of October 29, 2023, is version 3.12.
  2. Python 3.12 no longer includes setuptools by default when a new virtual environment is created, thereby causing the absence of pkg_resources.
  3. Given this, the solution could be that interrogate should explicitly depend on setuptools.

I discovered this issue because of my CI/CD pipelines failing. One example is in LlamaBot, linked here.

thomasjpfan commented 8 months ago

The issue with pkg_resources is fixed in master with this commit: https://github.com/econchick/interrogate/commit/3aa94a6a9d6dca0a015d97ef389feb788cb466dd

In the commit, import pkg_resources was replaced with from importlib import resources. I suspect this issue will be resolved when 1.6.0 is released.

Chouvic commented 5 months ago

Any update on this issue's release date please?

econchick commented 3 months ago

released 1.6.0! closing this issue, but if it isn't fixed, feel free to re-open.