prospector icon indicating copy to clipboard operation
prospector copied to clipboard

[BUG] KeyError: 'version' when running in a folder with pyproject.toml which contains a path dependency

Open char0lene opened this issue 2 years ago • 2 comments

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

  1. have 2 poetries (in different directories)
  2. include a path dependency in one poetry (A) to the other poetry (B)
  3. open a terminal in the folder with poetry A
  4. 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.

char0lene avatar Feb 10 '23 08:02 char0lene

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 🤞

bellmatt avatar Feb 15 '23 13:02 bellmatt

#556 is closed as fixed in 1.10 can this one also be closed?

sbrunner avatar Oct 17 '24 12:10 sbrunner