Skip to content

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

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

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

Conversation

@wayu15244

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.

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

1 participant