Skip to content

Commit 44bf74a

Browse files
committed
Fix pipenv update --dev updating transitive deps independently
When running 'pipenv update --dev' or 'pipenv update --categories develop', transitive dependencies in the develop section were being updated independently from the default section. This could result in version bumps (including major version changes) for shared packages between default and develop. The fix adds the same 'overwrite_with_default()' logic from lock.py to update.py, ensuring that any packages present in both default and develop sections use the version from default. Fixes #6420
1 parent 27821d4 commit 44bf74a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

news/6420.bugfix.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Fix ``pipenv update --dev`` (and ``pipenv update --categories develop``) updating
2+
transitive dependencies in the ``develop`` section independently from the ``default``
3+
section. Now, any packages that appear in both ``default`` and ``develop`` will use
4+
the version from ``default``, ensuring consistent dependency versions between
5+
production and development environments.
6+
7+
Fixes #6420

pipenv/routines/update.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pipenv.exceptions import JSONParseError, PipenvCmdError
99
from pipenv.patched.pip._vendor.packaging.specifiers import SpecifierSet
1010
from pipenv.patched.pip._vendor.packaging.version import InvalidVersion, Version
11+
from pipenv.routines.lock import overwrite_with_default
1112
from pipenv.routines.outdated import do_outdated
1213
from pipenv.routines.sync import do_sync
1314
from pipenv.utils import err
@@ -653,6 +654,16 @@ def upgrade(
653654
if not has_package_args:
654655
package_args = []
655656

657+
# Overwrite any non-default category packages with default packages (if present)
658+
# This ensures transitive dependencies in develop match the versions from default
659+
for category in categories:
660+
if category == "default":
661+
continue
662+
if lockfile.get(category):
663+
lockfile[category].update(
664+
overwrite_with_default(lockfile.get("default", {}), lockfile[category])
665+
)
666+
656667
# Update and write lockfile
657668
lockfile.update({"_meta": project.get_lockfile_meta()})
658669
project.write_lockfile(lockfile)

0 commit comments

Comments
 (0)