From 6b61b7abd9e9b83663e41fcc5bcc9a018b71280d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 21 Nov 2023 10:45:12 +0100 Subject: [PATCH] Make `project.get_default_index()` populate a default name Otherwise using pipenv with a Pipfile the defaults a source without a name causes a KeyError like: ``` Traceback (most recent call last): File "/usr/local/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pipenv/resolver.py", line 675, in main() File "/usr/local/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pipenv/resolver.py", line 661, in main _main( File "/usr/local/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pipenv/resolver.py", line 645, in _main resolve_packages( File "/usr/local/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pipenv/resolver.py", line 612, in resolve_packages results, resolver = resolve( ^^^^^^^^ File "/usr/local/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pipenv/resolver.py", line 592, in resolve return resolve_deps( ^^^^^^^^^^^^^ File "/usr/local/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pipenv/utils/resolver.py", line 910, in resolve_deps results, hashes, internal_resolver = actually_resolve_deps( ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pipenv/utils/resolver.py", line 672, in actually_resolve_deps resolver = Resolver.create( ^^^^^^^^^^^^^^^^ File "/usr/local/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pipenv/utils/resolver.py", line 222, in create index_lookup[package_name] = project.get_default_index()["name"] ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ KeyError: 'name' ``` --- news/6021.bugfix.rst | 1 + pipenv/project.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 news/6021.bugfix.rst diff --git a/news/6021.bugfix.rst b/news/6021.bugfix.rst new file mode 100644 index 0000000000..c3c82ca55c --- /dev/null +++ b/news/6021.bugfix.rst @@ -0,0 +1 @@ +Fix KeyError when using a source without a name in Pipfile diff --git a/pipenv/project.py b/pipenv/project.py index 9495370e97..f06ef93cc0 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -1023,7 +1023,7 @@ def pipfile_sources(self, expand_vars=True): return sources def get_default_index(self): - return self.pipfile_sources()[0] + return self.populate_source(self.pipfile_sources()[0]) def get_index_by_name(self, index_name): for source in self.pipfile_sources():