Skip to content

Cleanup unused dependencies #6386

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

Merged
merged 6 commits into from
Apr 25, 2025
Merged

Cleanup unused dependencies #6386

merged 6 commits into from
Apr 25, 2025

Conversation

matteius
Copy link
Member

@matteius matteius commented Apr 24, 2025

Thank you for contributing to Pipenv!

The issue

Fixes #

The checklist

  • Associated issue
  • A news fragment in the news/ directory to describe this fix with the extension .bugfix.rst, .feature.rst, .behavior.rst, .doc.rst. .vendor.rst. or .trivial.rst (this will appear in the release changelog). Use semantic line breaks and name the file after the issue number or the PR #.

@matteius matteius requested a review from Copilot April 25, 2025 07:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR cleans up unused dependencies after upgrading packages by removing entries from the lockfile that are no longer required.

  • Added an integration test (tests/integration/test_upgrade_cleanup.py) that verifies the removal of now-unused dependencies.
  • Introduced a new helper function (_clean_unused_dependencies) in pipenv/routines/update.py to perform the cleanup.
  • Updated the upgrade process to store the original lockfile and remove stale entries post-dependency resolution.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/integration/test_upgrade_cleanup.py New integration test to verify removal of unused dependencies
pipenv/routines/update.py Added _clean_unused_dependencies and updated upgrade workflow to invoke it
Files not reviewed (1)
  • news/6386.bugfix.rst: Language not supported
Comments suppressed due to low confidence (1)

pipenv/routines/update.py:492

  • [nitpick] A shallow copy is used for 'original_lockfile', which might lead to unintended shared references if the inner dictionaries are mutated. Consider using a deep copy to ensure the original lockfile remains unaffected by later modifications.
    original_lockfile = { k: v.copy() if isinstance(v, dict) else v for k, v in lockfile.items() }

@matteius matteius force-pushed the remove-dead-dependencies branch from 4f295f7 to 68cbf59 Compare April 25, 2025 07:45
import pytest


@pytest.mark.upgrade
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@oz123 oz123 merged commit 000b5ba into main Apr 25, 2025
20 of 24 checks passed
@oz123 oz123 deleted the remove-dead-dependencies branch April 25, 2025 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants