TOML formatting and validation#2025
Conversation
braingram
left a comment
There was a problem hiding this comment.
Thanks. What is the state of taplo? I ask because while testing if pre-commit autoupdate would work I noticed the latest release on pypi 0.9.3 is from Aug 2024. It appears the original maintainer is no longer maintaining it tamasfe/taplo#715 and projects are moving away from using it. Also while looking up default-schema-catalogs the docs point to a dead link: https://www.schemastore.org/json/ so I'm not sure what "validate" is doing here.
One of the projects that moved away from taplo mentions https://github.com/tombi-toml/tombi is that a suitable alternative?
|
Taplo is getting occasional updates (at least to the VSCode plugin) and seems more stable than Tombi (e.g. 4M downloads for the Tombi VSCode extension vs 10k for Taplo). Testing Tombi it seems to produce the same results in terms of both formatting and linting as Taplo, but it also has a first-party precommit hook so that seems like a good option. |
braingram
left a comment
There was a problem hiding this comment.
It looks like tombi is reordering things. Can we globally disable this? It does support inline comments to disable sorting but so far I've only been able to get them to apply to one item so we'd have to either:
- add auto-sorting disable to each item we want to disable
- define a new custom schema
neither seems very helpful here.
| test = ["asdf[tests]"] | ||
| tests = ["asdf[all]", "psutil", "pytest>=8"] |
There was a problem hiding this comment.
| test = ["asdf[tests]"] | |
| tests = ["asdf[all]", "psutil", "pytest>=8"] | |
| tests = ["asdf[all]", "psutil", "pytest>=8"] | |
| test = ["asdf[tests]"] |
Since test is essentially an alias of tests I think this ordering makes more sense. How do we stop this from being reordered?
There was a problem hiding this comment.
Yeah it seems like there's no way to prevent reordering other than on a case-by-case basis (relevant issue).
Lack of configurability seems to be a common complaint about Tombi. In the Taplo github issues several people cite it as the reason they haven't switched over.
We can just switch back to Taplo? It doesn't seem to be getting new features but there are at least maintenance updates happening and the actual schema validation references SchemaStore which is updated independently.
There was a problem hiding this comment.
Actually, looks like Tombi does respect blank lines so that could work.
I went ahead and updated pyproject.toml to restore the ordering for the two tables you mentioned. Let me know if that works for you as a solution.
| dependencies = [ | ||
| "asdf-standard>=1.1.0", | ||
| # for vendorized jsonschema | ||
| "attrs>=22.2.0", |
There was a problem hiding this comment.
How do we prevent this from being reordered? It now no longer aligns with the # end comment.
| 'asdf.resource_mappings' = {asdf = 'asdf._core._integration:get_json_schema_resource_mappings'} | ||
| asdf_extensions = {builtin = 'asdf.extension._legacy:BuiltinExtension'} | ||
| console_scripts = {asdftool = 'asdf._commands.main:main'} | ||
| asdf_extensions = { builtin = "asdf.extension._legacy:BuiltinExtension" } |
There was a problem hiding this comment.
Just a note that I think we can remove this (in a different PR).
braingram
left a comment
There was a problem hiding this comment.
Thanks for working through this. I can't say I'm entirely a fan of the new formatting but it's certainly an improvement to have something enforced.
Description
pyproject.tomlpyproject.tomlto conform to Pyproject schemavalidate-pyprojectprecommit hookCloses #2022