Skip to content

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

@char0lene

Description

@char0lene

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions