Skip to content

feat: add TOML 1.1 support with multiline inline tables#5655

Draft
baszalmstra wants to merge 12 commits intomainfrom
claude/update-toml-multiline-tables-Mhrjf
Draft

feat: add TOML 1.1 support with multiline inline tables#5655
baszalmstra wants to merge 12 commits intomainfrom
claude/update-toml-multiline-tables-Mhrjf

Conversation

@baszalmstra
Copy link
Contributor

Description

Update TOML crates to support the TOML 1.1 specification, which introduces multiline inline tables and trailing commas. This improves readability of pixi.toml files by allowing users to write:

[dependencies]
python = {
    version = ">=3.12",
    channel = "conda-forge",
}

Crate updates (minimum versions for TOML 1.1):

  • toml-span: 0.6.0 → 0.7.0 (TOML 1.1 parsing support)
  • toml_edit: 0.23.0 → 0.25.0 (TOML 1.1 editing support)

Documentation updated to note TOML 1.1 support in the manifest reference.

How Has This Been Tested?

Added 6 new tests in pixi_manifest:

  • 3 manifest parsing tests — verify multiline inline tables with trailing commas parse successfully for dependencies, nested build backend config, and mixed formatting
  • 2 document editing tests (insta snapshots) — verify toml_edit preserves multiline inline table formatting when parsing and inserting values
  • 1 error span test (insta snapshot) — verifies diagnostics point to the exact value inside a multiline inline table:
      8 │         bad-pkg = {
      9 │             version = "!invalid!",
        ·                        ─────────
     10 │             channel = "conda-forge",
    

All 285 pixi_manifest tests pass. Full project builds cleanly (cargo check succeeds).

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude Code

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.

claude added 9 commits March 11, 2026 10:31
Update toml-span from 0.6.0 to 0.7.1 (adds TOML 1.1 spec support),
toml from 0.9.8 to 0.9.11, and toml_edit from 0.23.0 to 0.23.7.

Add tests demonstrating multiline inline table parsing in both the
manifest parser (toml-span) and document editor (toml_edit). Document
the TOML 1.1 multiline inline table support in the manifest reference.

https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
… test

- Use insta snapshots in all multiline inline table tests to verify
  parsed content and formatting are correct
- Bump toml-span to 0.7.0 (minimum for TOML 1.1 support)
- Bump toml_edit to 0.24.0 (minimum for official TOML 1.1 support)
- Revert toml to 0.9.8 (not needed for pixi.toml parsing)
- Add error span test to verify diagnostics point to correct locations
  inside multiline inline tables

https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
- Bump toml_edit from 0.24.0 to 0.25.0 (latest minor with parsing fixes)
- Remove insta snapshots from parse-only manifest tests — these only
  need to verify parsing succeeds via unwrap()
- Keep insta snapshots for document editing tests (verify formatting)
  and error span test (verify diagnostic locations)

https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
Change the error span test to use an invalid version value ("!invalid!")
so the diagnostic points to the value itself (line 9, col 24) rather
than the whole table. This verifies toml-span correctly tracks spans
within multiline inline tables at field-level granularity.

https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
- Bump toml from 0.9.8 to 0.9.10 (minimum for TOML 1.1 support)
- Fix insert_into_inline_table to place new entries on their own line
  when the existing table uses multiline formatting. Detects indentation
  from existing entries and applies matching decoration to the new key.

https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
Fix the space-before-comma artifact (` ,`) by clearing value suffix
decoration. Preserve the original trailing comma style: if the table
had a trailing comma, the new entry gets one too; if not, it doesn't.
Ensure the closing `}` stays on its own line in both cases.

Add test for the no-trailing-comma case to verify both styles.

https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
When inserting into a multiline inline table, detect whether the
existing keys are sorted (case-insensitive). If sorted, insert the new
key at the correct position to maintain order. If unsorted, append at
the end to preserve the user's custom ordering.

Extracted small, independently testable helpers:
- is_sorted_case_insensitive: checks if a key list is sorted
- sorted_insert_position: binary search for the insertion index
- detect_inline_table_indentation: extracts multiline indent

Added 15 new tests: 10 unit tests for the helpers, 4 integration tests
for sorted/unsorted/mixed-case/start-position insertion, plus the
existing trailing comma tests.

https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
Reverts the following commits:
- feat: sorted insertion for multiline inline tables
- fix: preserve trailing comma style in multiline inline table insertion
- feat: bump toml to 0.9.10, fix multiline inline table insertion

https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
- Bump toml from 0.9.8 to 0.9.10 (minimum for TOML 1.1 support)
- Fix insert_into_inline_table to place new entries on their own line
  when the existing table uses multiline formatting
- Fix space-before-comma artifact by clearing value suffix decoration
- Preserve trailing comma style: if the table had a trailing comma the
  new entry gets one too; if not, it doesn't
- Ensure closing `}` stays on its own line in both cases
- Add test for the no-trailing-comma variant

https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
- Let rustfmt reformat the key builder chain
- Replace useless format!("\n") with "\n".to_string()

https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
Copy link
Contributor

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

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

Really excited for this. I'd like to play a bit more with it locally before we merge it

Replace external .snap files with inline snapshot strings for the
two multiline inline table insertion tests.

https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
@Hofer-Julian
Copy link
Contributor

Hofer-Julian commented Mar 11, 2026

pixi add behaves a bit weird here:

[workspace]
authors = ["Julian Hofer <julianhofer@gnome.org>"]
channels = ["conda-forge"]
name = "toml-1.1"
platforms = ["linux-64"]
version = "0.1.0"

[tasks]

[feature.test]
dependencies = {
    numpy = "*"
}

[environments]
test = ["test"]

Then run pixi add --feature test pydantic gives me this:

[feature.test]
dependencies = {
    numpy = "*"
, pydantic = ">=2.12.5,<3" }

I would have expected:

[feature.test]
dependencies = {
    numpy = "*",
    pydantic = ">=2.12.5,<3", 
}

Adds an explicit test reproducing the issue from PR #5655 comment
where inserting into a single-entry multiline inline table without a
trailing comma could produce malformatted output. The fix already
handles this case correctly.

https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
@baszalmstra baszalmstra marked this pull request as draft March 12, 2026 08:38
@baszalmstra
Copy link
Contributor Author

I converted to draft because I think this could be integrated better in more places. Im working on that now.

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

Successfully merging this pull request may close these issues.

3 participants