uv icon indicating copy to clipboard operation
uv copied to clipboard

(🐞) `uv remove` deletes comments

Open KotlinIsland opened this issue 1 year ago • 1 comments

[project]
name = "python-test"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
dependencies = [
    # should be in alphabetical order
    "basedmypy[faster-cache]>=2.8.1", # this is a comment
    "basedpyright>=1.18.2,<2.0.0",
]
> uv remove basedmypy
[project]
name = "python-test"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
dependencies = [ # this is a comment
    "basedpyright>=1.18.2,<2.0.0",
]

KotlinIsland avatar Dec 13 '24 00:12 KotlinIsland

I think this is arguably correct... The comment is associated with the dependency. In some cases it would probably be equally strange not to remove it? Like what if the comment described basedmypy.

charliermarsh avatar Dec 15 '24 02:12 charliermarsh

"The comment is associated with the dependency"

This assumption holds for inline comments, but holds 50% for non-inline comments. I'm OK with removing the inline comments, but I would dislike it that non-inline commens are removed, preceding or not.

woutervh avatar Dec 21 '24 23:12 woutervh

It seems reasonable to err on the side of preserving comments.

charliermarsh avatar Dec 22 '24 00:12 charliermarsh

I suspect we should remove the comments if we're removing the last dependency in the list.

charliermarsh avatar Dec 22 '24 17:12 charliermarsh

I suspect we should remove the comments if we're removing the last dependency in the list. agreed

woutervh avatar Dec 23 '24 13:12 woutervh

Hi I am a QA engineer, and I use a template-like pyproject.toml and have several lists with several commented out elements. Depending on what I have to test, I uncomment the appropriate dependency.

Also sometimes add the commented out dependency before uninstalling it in order to have it in the toml file. (for next time)

I had to revert the toml file to get back my comments. ...

There are as many kind of human behavior why they add some comment ...

So I think uv should not remove comments from the toml file. Right now uv remove command does not "do one thing well" (remove package, and its sub-dependencies and remove the registry of that). It does one expected thing, and one unexpected.

BR, George

GeorgeFischhof avatar Apr 09 '25 09:04 GeorgeFischhof

I'd like to take this up.

kiran-4444 avatar Apr 10 '25 21:04 kiran-4444