Skip to content

TOML formatting and validation#2025

Merged
braingram merged 7 commits into
asdf-format:mainfrom
sydduckworth:toml-formatting
Apr 17, 2026
Merged

TOML formatting and validation#2025
braingram merged 7 commits into
asdf-format:mainfrom
sydduckworth:toml-formatting

Conversation

@sydduckworth
Copy link
Copy Markdown
Contributor

Description

  • Added Taplo format and validate steps to precommit config
  • Formatted pyproject.toml
  • Updated pyproject.toml to conform to Pyproject schema
  • Removed validate-pyproject precommit hook

Closes #2022

Copy link
Copy Markdown
Contributor

@braingram braingram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread .pre-commit-config.yaml
Comment thread .pre-commit-config.yaml Outdated
@sydduckworth
Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

@braingram braingram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pyproject.toml Outdated
Comment on lines +39 to +40
test = ["asdf[tests]"]
tests = ["asdf[all]", "psutil", "pytest>=8"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pyproject.toml Outdated
dependencies = [
"asdf-standard>=1.1.0",
# for vendorized jsonschema
"attrs>=22.2.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we prevent this from being reordered? It now no longer aligns with the # end comment.

Comment thread pyproject.toml
'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" }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note that I think we can remove this (in a different PR).

Copy link
Copy Markdown
Contributor

@braingram braingram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@braingram braingram merged commit c5541d6 into asdf-format:main Apr 17, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add TOML formatting to Precommit

2 participants