fix: don't mutate cached parsed_pipfile when locking deps#6657
Merged
fix: don't mutate cached parsed_pipfile when locking deps#6657
Conversation
get_locked_dep popped ``version`` and ``ref`` directly off the entry it received from ``pipfile_section``. Since #6649 made ``parsed_pipfile`` return a cached TOMLDocument by reference, those pops persisted across the rest of the pipenv invocation — a subsequent ``write_toml`` (e.g. ``add_pipfile_entry_to_pipfile`` for the newly installed package) would emit ``six = {}`` instead of ``six = {version = "*"}`` and strip the version from any inline-table or outline-table siblings. Copy the dict before scrubbing those keys. Add a unit regression test that asserts get_locked_dep leaves the section untouched. Fixes the integration regression hit by ``test_rewrite_outline_table`` and ``test_rewrite_outline_table_ooo`` on main since the pip 26.1 vendoring run. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_locked_depwas poppingversion/refoff the entry it received frompipfile_section. Since perf: cache Pipfile parse, parallelize hash/candidate lookups, harden benchmark runner #6649 madeparsed_pipfilereturn a cachedTOMLDocumentby reference, those pops persisted for the rest of the invocation — a follow-upwrite_toml(e.g. whenadd_pipfile_entry_to_pipfileadds the newly installed package) would emitsix = {}and strip theversionfrom sibling inline/outline-table entries.get_locked_depleaves the section untouched.This fixes the integration regression that made
test_rewrite_outline_tableandtest_rewrite_outline_table_ooostart failing on every CI run since the pip 26.1 vendor PR (#6656) merged. (The cache-by-reference change in #6649 introduced the latent bug; #6656 is just when it became consistently observable.)Test plan
tests/unit/test_locking_no_mutation.pyfails onmainand passes with this fixpipenv install coloramaagainst a Pipfile withsix = {version = "*"}and[packages.requests]now preserves both entries' versions instead of producingsix = {}/requests = {extras = ["socks"]}test_rewrite_outline_table/test_rewrite_outline_table_oooNotes on other CI failures (not in scope here)
test_install_with_pipfile_including_invalid_python_version— stale; pipenv now supports PEP 440 specifiers inpython_version(feat(#5195): support PEP 440 version specifiers in Pipfile python_version #6606), so the install correctly succeeds. Test should be updated/removed separately.test_install_github_vcs[*]— thereagento/adaptix.git@2.16VCS dep no longer resolves under pip 26.1 (No matching distribution found for dataclass-factory). Needs a separate look at pip's resolvelib factory changes.🤖 Generated with Claude Code