Skip to content
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

Open
l0b0 opened this issue Dec 20, 2023 · 7 comments
Open

pretty-format-toml removes trailing comments in list #202

l0b0 opened this issue Dec 20, 2023 · 7 comments

Comments

@l0b0
Copy link

l0b0 commented Dec 20, 2023

When reformatting a list setting like

load-plugins = [
  "pylint.extensions.bad_builtin",
  # "pylint.extensions.docparams",
  "pylint.extensions.set_membership"
  # "pylint.extensions.typing"
]

, 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.

@maresb
Copy link
Contributor

maresb commented Jan 20, 2024

This looks like a duplicate of #161

@maresb
Copy link
Contributor

maresb commented Jan 20, 2024

I feel like this TOML pre-commit hook needs a big red warning that it's unsafe since it will unceremoniously delete comments.

@Avasam
Copy link

Avasam commented Aug 18, 2024

I find it'll do so even outside lists. And I have no workaround, making this hook pretty unusable.
It also removes newlines between blocks of comments

@corneliusroemer
Copy link

Yes, TOML needs to be fixed or marked unsafe as it removes comments - don't use!

image

corneliusroemer added a commit to corneliusroemer/language-formatters-pre-commit-hooks that referenced this issue Aug 18, 2024
@maresb
Copy link
Contributor

maresb commented Aug 21, 2024

@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!

@corneliusroemer
Copy link

@maresb That is for reminding me! I must have forgotten to make a PR. Done now! #242

@maresb
Copy link
Contributor

maresb commented Aug 23, 2024

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.):

https://github.com/ComPWA/mirrors-taplo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants