From fc41978bbb02c2883c087614f4a3cc914785743c Mon Sep 17 00:00:00 2001 From: Isheros Date: Sun, 6 Dec 2020 21:54:38 -0600 Subject: [PATCH 1/4] Added set sources to DEFAULT_SOURCE if the section does not exist in the PIPFILE --- pipenv/project.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pipenv/project.py b/pipenv/project.py index 62dffd74..6feb05c7 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -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 { From 24839f3c26a8fdd4d2e3ed44ff119172aa2311e9 Mon Sep 17 00:00:00 2001 From: Isheros Date: Sun, 6 Dec 2020 22:32:29 -0600 Subject: [PATCH 2/4] Added news fragment --- news/4141.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/4141.bugfix.rst diff --git a/news/4141.bugfix.rst b/news/4141.bugfix.rst new file mode 100644 index 00000000..7a60a91d --- /dev/null +++ b/news/4141.bugfix.rst @@ -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.'" \ No newline at end of file From 122379026aa25bdad083328ac67fa5fb4deed701 Mon Sep 17 00:00:00 2001 From: Isheros Date: Mon, 7 Dec 2020 01:48:42 -0600 Subject: [PATCH 3/4] Added a test for the bug --- tests/integration/test_project.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/integration/test_project.py b/tests/integration/test_project.py index dac05d34..fe3682d0 100644 --- a/tests/integration/test_project.py +++ b/tests/integration/test_project.py @@ -230,3 +230,18 @@ 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 +@pytest.mark.needs_internet +def test_not_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 + From dc882677e95be48a5737eb312c0adc669098d18d Mon Sep 17 00:00:00 2001 From: Isheros Date: Mon, 7 Dec 2020 01:51:02 -0600 Subject: [PATCH 4/4] Added fix for bug 4141 --- tests/integration/test_project.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/integration/test_project.py b/tests/integration/test_project.py index fe3682d0..44872b0e 100644 --- a/tests/integration/test_project.py +++ b/tests/integration/test_project.py @@ -233,8 +233,7 @@ def test_run_in_virtualenv(PipenvInstance): @pytest.mark.project @pytest.mark.sources -@pytest.mark.needs_internet -def test_not_sources_in_pipfile(PipenvInstance): +def test_no_sources_in_pipfile(PipenvInstance): with PipenvInstance(chdir=True) as p: with open(p.pipfile_path, 'w') as f: contents = """