Fix #83: remove stale entries from [tool.uv.sources]#91
Merged
Conversation
mxdev tags each source entry it writes with a '# managed by mxdev' marker comment and reconciles them on every run: managed entries whose package was removed from mx.ini (or switched to install-mode = skip) are pruned, while user-defined sources without the marker are left untouched.
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.
Fixes #83.
Problem
When a package is removed from
mx.ini, its entry in[tool.uv.sources]is not removed frompyproject.toml. The uv hook only ever adds/overwrites the sources of packages currently inmx.ini; there is no reconciliation that prunes entries whose package was dropped. (Root-cause analysis: see issue comment.)[tool.uv.sources]is a shared table that may also hold user-defined sources (git/url/workspace/path entries not created by mxdev), so it cannot simply be cleared — mxdev must distinguish the entries it manages.Approach
mxdev tags every source it writes with a trailing marker comment (
# managed by mxdev). On each run it:mx.ini(or switched toinstall-mode = skip),A tomlkit spike confirmed the marker round-trips and the reconcile is idempotent (byte-identical rewrites). Migration note: entries written by older mxdev versions carry no marker; active packages get re-tagged on the first run, so only a package removed before upgrading would leave a one-time orphan.
Status
This draft currently contains the failing tests reproducing the bug. The fix follows in the next commit.
Test Plan
test_drops_source_when_package_removed_from_mx_initest_preserves_foreign_sources_when_reconcilingtest_skip_install_mode_removes_existing_sourcetest_source_reconcile_idempotency