Skip to content

Fix #83: remove stale entries from [tool.uv.sources]#91

Merged
jensens merged 2 commits into
mainfrom
fix/83-remove-stale-uv-sources
May 31, 2026
Merged

Fix #83: remove stale entries from [tool.uv.sources]#91
jensens merged 2 commits into
mainfrom
fix/83-remove-stale-uv-sources

Conversation

@jensens
Copy link
Copy Markdown
Member

@jensens jensens commented May 31, 2026

Fixes #83.

Problem

When a package is removed from mx.ini, its entry in [tool.uv.sources] is not removed from pyproject.toml. The uv hook only ever adds/overwrites the sources of packages currently in mx.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:

  1. removes managed entries (marker present) whose package is no longer in mx.ini (or switched to install-mode = skip),
  2. (re)writes the current managed entries with the marker,
  3. never touches entries without the marker.

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_ini
  • test_preserves_foreign_sources_when_reconciling
  • test_skip_install_mode_removes_existing_source
  • test_source_reconcile_idempotency
  • full suite + lint green

jensens added 2 commits May 31, 2026 23:30
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.
@jensens jensens marked this pull request as ready for review May 31, 2026 21:37
@jensens jensens merged commit da0b792 into main May 31, 2026
17 checks passed
@jensens jensens deleted the fix/83-remove-stale-uv-sources branch May 31, 2026 21:39
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.

source not removed from "[tool.uv.sources]"

1 participant