(🐞) `uv remove` deletes 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",
]
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.
"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.
It seems reasonable to err on the side of preserving comments.
I suspect we should remove the comments if we're removing the last dependency in the list.
I suspect we should remove the comments if we're removing the last dependency in the list. agreed
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
I'd like to take this up.