-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uv does not respect position of comments in pyproject.toml
#8343
Comments
I suppose that's a legitimate bug though end-of-line comments are my mortal enemy from working on the formatter and I don't know if I can work up the courage to fix it myself :) |
Tricky one. The fun thing is that the "current dependency line comment" in this case is becoming a next dependency |
…al-sh#8384) ## Summary This PR is is to address the problem when the same-line comments in `pyproject.toml` could be found in unpredictable positions after `uv add` or `remove` reformats the `pyproject.toml` file. Introduced the `Comment` structure in `pyproject_mut` module to distinguish "same-line" comments and "full-line" comments while reformatting, because logic for them differs. Sorry, the implementation could be clumsy, I'm just learning Rust, but it seems to work 😅 Closes astral-sh#8343 ## Test Plan Added the new test: `add_preserves_comments_indentation_and_sameline_comments` To test followed the actions from the issue ticket astral-sh#8343 --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
uv 0.4.24
Maybe this is already reported but I couldn't find it.
Steps to reproduce:
1,
uv init temp
2.
cd temp
3.
uv add requests
4.
uv add whenever~=0.6.9
5. Edit
project.dependencies
inpyproject.toml
from:To:
uv add uv zope
project.dependencies
inpyproject.toml
:Actual output:
Expected output:
Context:
I often leave comments in my
pyproject.toml
to explain why a particular dependency is pinned or given an upper bound.I appreciate that comments are a hard problem when reading and writing toml, and there will always be edge cases where the user needs to manually update them (e.g. a requirement is removed), but I don't think this example is an edge case.
The text was updated successfully, but these errors were encountered: