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

TOML Trailing Comma bug #6636

Closed
ddelange opened this issue Dec 17, 2023 · 5 comments
Closed

TOML Trailing Comma bug #6636

ddelange opened this issue Dec 17, 2023 · 5 comments
Labels

Comments

@ddelange
Copy link

Describe the bug

Hi 👋

TOML allows trailing comma in inline arrays ref toml-lang/toml#246 (comment).

Here's an example TOML where the trailing comma causes a bug (incorrect red highlight onwards): https://github.com/ddelange/mapply/blob/0.1.23/pyproject.toml#L60

[tool.ruff]
select = ["ALL"]
ignore = [
  "D107", # we have pydoclint with class docstring
  "D407", # we have google style docstrings
  "E501", # we have black
  "ANN", # we have mypy
  "TRY003", # there is EM102
  "D203", # there is D211
  "D213", # there is D212
  "FIX002", # there is TD002,TD003
]

[tool.ruff.extend-per-file-ignores]
"**/tests/**/*.py" = [
  "S101", # assert is fine in tests
  "D100", # tests is not a package
  "D104", # tests modules don't need docstrings
]

Expected behaviour

Code following the inline array with trailing comma should not have red highlight.

Related discussion

Additional notes

@ddelange ddelange added the Bug label Dec 17, 2023
@lildude
Copy link
Member

lildude commented Dec 18, 2023

As per the troubleshooting doc, this is a problem with the upstream grammar. Please open an issue there.

@lildude lildude closed this as not planned Won't fix, can't repro, duplicate, stale Dec 18, 2023
@ahvigil
Copy link

ahvigil commented Jan 2, 2024

is it possible the upstream grammar is being improperly applied somehow? The textmate toml bundle seems to parse fine in TextMate itself- but you can see even some of the official toml spec test cases show up with error highlights in the github rendering.

I can't pin this down exactly but I don't remember toml files rendering this way in the past and neither the toml spec nor the upstream grammar have changed in years. I feel like I would've noticed this in one of the many pyproject.toml files that now highlight in red. 🤷

@Alhadis
Copy link
Collaborator

Alhadis commented Jan 2, 2024

@ahvigil This isn't the fault of the TextMate grammar. There appears to have been a change in GitHub's own PrettyLights highlighter; the grammar itself is valid and no changes to it are necessary. See #6603 (comment) for more details.

@lildude
Copy link
Member

lildude commented Jan 2, 2024

I've opened #6668 to track the highlighting issues in one place

@jtbandes
Copy link
Contributor

jtbandes commented Jan 2, 2024

Also, for what it's worth I believe the issue here is triggered by the line comment, not the trailing comma. It looks fine if I remove the last comment in the ignore list:

[tool.ruff]
select = ["ALL"]
ignore = [
  "D107", # we have pydoclint with class docstring
  "D407", # we have google style docstrings
  "E501", # we have black
  "ANN", # we have mypy
  "TRY003", # there is EM102
  "D203", # there is D211
  "D213", # there is D212
  "FIX002   ---> comment removed here",
]

[tool.ruff.extend-per-file-ignores]
"**/tests/**/*.py" = [
  "S101", # assert is fine in tests
  "D100", # tests is not a package
  "D104", # tests modules don't need docstrings
]

@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants