Pre-commit hook
Environment
interrogateversion(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)
- Use Python version 3.12.0 for your virtual environment.
- Install
pre-commitwith a.pre-commit-config.yamlthat includesinterrogateas one of the hooks. - 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:
pre-commitdefaults to using the latest Python version available, which, as of October 29, 2023, is version 3.12.- Python 3.12 no longer includes
setuptoolsby default when a new virtual environment is created, thereby causing the absence ofpkg_resources. - Given this, the solution could be that
interrogateshould explicitly depend onsetuptools.
I discovered this issue because of my CI/CD pipelines failing. One example is in LlamaBot, linked here.
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.
Any update on this issue's release date please?
released 1.6.0! closing this issue, but if it isn't fixed, feel free to re-open.