Skip to content

Commit

Permalink
Make project.get_default_index() populate a default name
Browse files Browse the repository at this point in the history
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 <module>
    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'

```
  • Loading branch information
deivid-rodriguez committed Nov 21, 2023
1 parent 247a143 commit 7e759b1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 7e759b1

Please sign in to comment.