-
Notifications
You must be signed in to change notification settings - Fork 58
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
pretty-format-toml removes trailing comments in list #202
Comments
This looks like a duplicate of #161 |
I feel like this TOML pre-commit hook needs a big red warning that it's unsafe since it will unceremoniously delete comments. |
I find it'll do so even outside lists. And I have no workaround, making this hook pretty unusable. |
Related to macisamuele#202
@corneliusroemer I don't see a corresponding PR for the commit linked above. Is one on the way, or did I miss it? Thanks for following through with that! |
By the way, if people need a safe TOML pre-commit hook, this just became available a few days ago and it seems to work very well. (The previous version used a cumbersome Docker contaier.): |
Unfortunately, the hook is not unsafe. In the issue a few points were mentioned:
I could understand the argument that there might be better base library to use, and I would be welcoming PRs in this direction. |
Semantics isn't only about computers, though. Removing a comment definitely changes the semantics for any human readers. |
If it accidentally dropped comments whilst applying a fix it'd be one thing, since you can add them back and the formatting should be stable after that. But it currently removes certain comments without applying any real changes. Semantics of "unsafe" aside, the end result is I can't use this hook because it can't keep some comments. Concerning possible alternatives, as a formatter backend there's https://taplo.tamasfe.dev/ which is what backs the Even Better TOML VSCode extension. They don't have an official pre-commit.ci hook or GitHub action yet (tamasfe/taplo#535, tamasfe/taplo#470 & tamasfe/taplo#326) Edit: Actually, there's https://github.com/ComPWA/taplo-pre-commit, and for use in GitHub action in a python project, taplo is bundled as a wheel https://pypi.org/project/taplo/ |
@macisamuele, the issue of On the other hand, many people (including me) store critical contextual information in comments. I am unfamiliar with any popular formatter (other than As such, I have opened #249 as a follow-up to #242 as neutral statement of facts. |
When reformatting a list setting like
, the first comment is retained, but the second one is removed. Both comments should be retained. Not sure whether this is an issue with TomlSort or this repo.
The text was updated successfully, but these errors were encountered: