prospector
prospector copied to clipboard
[BUG] KeyError: 'version' when running in a folder with pyproject.toml which contains a path dependency
Describe the bug
When you start prospector in a folder with a pyproject.toml (from poetry). And this file does contain a path path dependency; Then prospector throws a KeyError and does not execute, because apparently it misses a dependency version. (You can not include a version in the path dependency, as far as I observed.)
To Reproduce
- have 2 poetries (in different directories)
- include a path dependency in one poetry (A) to the other poetry (B)
- open a terminal in the folder with poetry A
- run
prospector
Expected behavior
Traceback (most recent call last):
File "/home/user/.local/bin/prospector", line 8, in <module>
sys.exit(main())
File "/home/user/.local/lib/python3.10/site-packages/prospector/run.py", line 189, in
main
config = ProspectorConfig()
File "/home/user/.local/lib/python3.10/site-packages/prospector/config/__init__.py", l
ine 36, in __init__
self.libraries = self._find_used_libraries(self.config, self.profile)
File "/home/user/.local/lib/python3.10/site-packages/prospector/config/__init__.py", l
ine 205, in _find_used_libraries
for found_dep in autodetect_libraries(self.workdir):
File "/home/user/.local/lib/python3.10/site-packages/prospector/autodetect.py", line 9
0, in autodetect_libraries
libraries = find_from_requirements(path)
File "/home/user/.local/lib/python3.10/site-packages/prospector/autodetect.py", line 7
2, in find_from_requirements
reqs = find_requirements(path)
File "/home/user/.local/lib/python3.10/site-packages/requirements_detector/detect.py",
line 68, in find_requirements
requirements = from_pyproject_toml(poetry_toml)
File "/home/user/.local/lib/python3.10/site-packages/requirements_detector/detect.py",
line 116, in from_pyproject_toml
spec = spec["version"]
KeyError: 'version'
Environment (please complete the following information):
- OS: Kubuntu 22.04.
- Tool: prospector and poetry
- Prospector version: 1.8.4
- Python version: 3.10.6
Additional context
You need two pyproject.toml poetry files.
This looks like the same issue as https://github.com/PyCQA/prospector/issues/556 - there's a workaround in that issue if you need one. The fix for this in requirements_detector has been merged now, so hopefully a fixed version of prospector is not too far away 🤞
#556 is closed as fixed in 1.10 can this one also be closed?