Merge pull request #4554 from Isheros/issue-4141

Fix for: --skip-lock: tomlkit.exceptions.NonExistentKey: 'Key "source" does not exist
This commit is contained in:
Frost Ming
2021-01-20 18:33:41 -06:00
committed by GitHub
3 changed files with 18 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Fix a bug where passing --skip-lock when PIPFILE has no [SOURCE] section throws the error: "tomlkit.exceptions.NonExistentKey: 'Key "source" does not exist.'"
+3 -1
View File
@@ -821,8 +821,10 @@ class Project(object):
from .vendor.plette.lockfiles import PIPFILE_SPEC_CURRENT
if self.lockfile_exists:
sources = self.lockfile_content.get("_meta", {}).get("sources", [])
else:
elif "source" in self.parsed_pipfile:
sources = [dict(source) for source in self.parsed_pipfile["source"]]
else:
sources = self.pipfile_sources
if not isinstance(sources, list):
sources = [sources]
return {
+14
View File
@@ -230,3 +230,17 @@ def test_run_in_virtualenv(PipenvInstance):
c = p.pipenv("clean --dry-run")
assert c.return_code == 0
assert "click" in c.out
@pytest.mark.project
@pytest.mark.sources
def test_no_sources_in_pipfile(PipenvInstance):
with PipenvInstance(chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
contents = """
[packages]
pytest = "*"
""".format(os.environ['PIPENV_TEST_INDEX']).strip()
f.write(contents)
c = p.pipenv('install --skip-lock')
assert c.return_code == 0