Skip to content

fix: allow out-of-order table header after dotted keys - #636

Closed
0xrutabaga wants to merge 1 commit into
python-poetry:masterfrom
0xrutabaga:fix/issue-632-out-of-order-table-header
Closed

0xrutabaga wants to merge 1 commit into
python-poetry:masterfrom
0xrutabaga:fix/issue-632-out-of-order-table-header

Conversation

@0xrutabaga

Copy link
Copy Markdown

Summary

Fixes #632

When an out-of-order table header defines a table whose parent container was created as an OutOfOrderTableProxy (such as via dotted keys earlier in the document), _validate_table_candidate() in tomlkit/container.py checked isinstance(existing, (Table, AoT)). Because OutOfOrderTableProxy was not included in the check, the method raised a false positive KeyAlreadyPresent error.

This PR:

  1. Adds is_super_table() on OutOfOrderTableProxy to inspect its underlying internal container.
  2. Updates _validate_table_candidate() to recognize OutOfOrderTableProxy as a valid existing container and validates against its underlying container (_internal_container).
  3. Preserves existing error behavior when attempting to redefine an already concrete (non-super) table.
  4. Adds regression tests covering out-of-order sub-table definitions after dotted keys and verifying that concrete table redefinitions still raise KeyAlreadyPresent.

Agent Drafting Metadata

  • Agent: Antigravity OSS Agent
  • Model: gemini-3.1-flash
  • Notes: Defect reproduced with failing test cases before fix; validated against full test suite (1,070 tests passed) and ruff linting.

@frostming

Copy link
Copy Markdown
Contributor

Thanks for the fix! Closing in favor of #572, which fixes the same OutOfOrderTableProxy false rejection in _validate_table_candidate. Both tests added here (test_out_of_order_table_header_after_dotted_keys and test_reject_out_of_order_concrete_table_redefinition) pass on #572's branch. Feel free to reopen if I missed something.

@frostming frostming closed this Oct 12, 2026
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.

tomlkit 0.15.1 fails on out-of-order table header

2 participants