Skip to content

Preserve end-of-line comments on previous entries when removing dependencies#18557

Merged
zanieb merged 2 commits intoastral-sh:mainfrom
zaniebot:claude/investigate-uv-18555-EwRRt
Mar 19, 2026
Merged

Preserve end-of-line comments on previous entries when removing dependencies#18557
zanieb merged 2 commits intoastral-sh:mainfrom
zaniebot:claude/investigate-uv-18555-EwRRt

Conversation

@zanieb
Copy link
Copy Markdown
Member

@zanieb zanieb commented Mar 18, 2026

When a dependency is removed, toml_edit stores any trailing comments in the prefix of the next item. Our implementation did not account for this, causing trailing comments on a dependency to be dropped when the subsequent item is removed.

For example, when removing requests from:

dependencies = [
    "numpy", # essential comment
    "requests",
]

With this fix, the comment is preserved.

Closes #18555

@zanieb zanieb added the bug Something isn't working label Mar 18, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 18, 2026

Merging this PR will not alter performance

✅ 5 untouched benchmarks


Comparing zaniebot:claude/investigate-uv-18555-EwRRt (c3147c1) with main (46c9bac)

Open in CodSpeed

@zanieb zanieb force-pushed the claude/investigate-uv-18555-EwRRt branch 3 times, most recently from 1d64c27 to fb6ebb1 Compare March 19, 2026 00:11
When removing a dependency from `pyproject.toml`, end-of-line comments on
the previous dependency line were being lost. This happened because
`toml_edit` stores such comments in the prefix of the *next* array item.
When that item was removed, the comment was discarded.

Before removing items, transfer any comments from a removed item's prefix
to the next remaining item's prefix, or to the array trailing if no
remaining item follows.

Closes astral-sh#18555

https://claude.ai/code/session_01Q7gJr2bNJBKevDQZh7MDU9
@zanieb zanieb force-pushed the claude/investigate-uv-18555-EwRRt branch from fb6ebb1 to 9ec4bd8 Compare March 19, 2026 03:09
@zanieb zanieb marked this pull request as ready for review March 19, 2026 12:37
@zanieb zanieb force-pushed the claude/investigate-uv-18555-EwRRt branch from 6b520ef to c3147c1 Compare March 19, 2026 12:59
@zanieb zanieb merged commit 6d628da into astral-sh:main Mar 19, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

comments in a nearby line might be lost through uv remove

3 participants