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

Issue 5456 #5464

Merged
merged 4 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/5456.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix regression of lock generation that caused the keep-outdated behavior to be default.
9 changes: 8 additions & 1 deletion pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,13 @@ def do_lock(
err=True,
)

# Prune old lockfile category as new one will be created.
if not keep_outdated:
try:
del lockfile[category]
except KeyError:
pass

from pipenv.utils.resolver import venv_resolve_deps

# Mutates the lockfile
Expand Down Expand Up @@ -2026,7 +2033,7 @@ def do_outdated(project, pypi_mirror=None, pre=False, clear=False):
project, clear=clear, pre=pre, write=False, pypi_mirror=pypi_mirror
)
for category in project.get_package_categories(for_lockfile=True):
for package in lockfile[category]:
for package in lockfile.get(category, []):
try:
updated_packages[package] = lockfile[category][package]["version"]
except KeyError:
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ def __init__(self, path):
self.document["source"] = self.document.get("source", tomlkit.aot())
self.document["requires"] = self.document.get("requires", tomlkit.table())
self.document["packages"] = self.document.get("packages", tomlkit.table())
self.document["dev_packages"] = self.document.get("dev_packages", tomlkit.table())
self.document["dev-packages"] = self.document.get("dev-packages", tomlkit.table())
super().__init__()

def install(self, package, value, dev=False):
section = "packages" if not dev else "dev_packages"
section = "packages" if not dev else "dev-packages"
if isinstance(value, dict):
table = tomlkit.inline_table()
table.update(value)
Expand All @@ -233,10 +233,10 @@ def install(self, package, value, dev=False):
self.write()

def remove(self, package, dev=False):
section = "packages" if not dev else "dev_packages"
section = "packages" if not dev else "dev-packages"
if not dev and package not in self.document[section]:
if package in self.document["dev_packages"]:
section = "dev_packages"
if package in self.document["dev-packages"]:
section = "dev-packages"
del self.document[section][package]
self.write()

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,5 @@ def test_uninstall_multiple_categories(pipenv_instance_private_pypi):
c = p.pipenv('uninstall six --categories="prereq after"')
assert c.returncode == 0

assert "six" not in p.lockfile["prereq"]
assert "six" not in p.lockfile.get("prereq", {})
assert "six" not in p.lockfile["default"]