Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
char0lene opened this issue Feb 10, 2023 · 2 comments
Labels

Comments

@char0lene
Copy link

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.

@bellmatt
Copy link

This looks like the same issue as #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 🤞

@sbrunner
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants