interrogate icon indicating copy to clipboard operation
interrogate copied to clipboard

Pre-commit hook

Open ericmjl opened this issue 2 years ago • 2 comments

Environment

  • interrogate version(s): 1.5.0, as a pre-commit hook
  • Operating System(s): Ubuntu (CI/CD)
  • Python version(s): 3.12.0

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.

ericmjl avatar Oct 29 '23 14:10 ericmjl

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.

thomasjpfan avatar Nov 01 '23 17:11 thomasjpfan

Any update on this issue's release date please?

Chouvic avatar Feb 06 '24 09:02 Chouvic

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

econchick avatar Apr 06 '24 23:04 econchick