uv
a656f700 - Preserve inline comments when updating dependencies (#21008)

Commit
8 days ago
Preserve inline comments when updating dependencies (#21008) ## Summary We now preserve inline comments attached to the final dependency in a TOML array when `uv add` updates an existing requirement and the entry does not end in a comma. Without a trailing comma, `toml_edit` stores the inline comment in the final item's suffix. Our array formatter previously treated that suffix as a prefix, moving the comment onto the preceding dependency. Move the suffix into the array's trailing decoration before adding the comma so the comment remains attached to the updated dependency. For example, given: ```toml typing = [ "pandas-stubs>=2.0.2", "narwhals>=1.42.0" # narwhals are toothed whales ] ``` Updating `narwhals` now produces: ```toml typing = [ "pandas-stubs>=2.0.2", "narwhals>=1.42", # narwhals are toothed whales ] ``` The regression is covered by an optional-dependency integration test; all 11 related integration tests and 18 `pyproject_mut` tests pass, along with formatting and Clippy. Closes https://github.com/astral-sh/uv/issues/21006.
Author
Parents
Loading