Skip to content

Avoid capturing dotted keys after empty table replacement#535

Open
gaoflow wants to merge 1 commit into
python-poetry:masterfrom
gaoflow:fix-513-empty-dotted-table
Open

Avoid capturing dotted keys after empty table replacement#535
gaoflow wants to merge 1 commit into
python-poetry:masterfrom
gaoflow:fix-513-empty-dotted-table

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #513.

Summary

  • track whether rendering is still in the root/current table scope before emitting dotted assignments
  • force a table header only when a super table would otherwise emit dotted items in the wrong scope
  • add root and nested regression coverage for replacing a dotted-key table with an empty table

Verification

  • uv run --no-project --with pytest --with pyyaml python -m pytest tests/test_toml_document.py::test_replace_dotted_key_table_does_not_capture_following_dotted_key tests/test_toml_document.py::test_replace_nested_dotted_key_table_keeps_following_dotted_key -q
  • uv run --no-project --with pytest --with pyyaml python -m pytest tests/test_toml_document.py -q
  • uv run --no-project --with pytest --with pyyaml python -m pytest -q
  • uv run --no-project --with ruff ruff check tomlkit/container.py tests/test_toml_document.py
  • uv run --no-project --with ruff ruff format --check tomlkit/container.py tests/test_toml_document.py
  • python -m compileall tomlkit/container.py tests/test_toml_document.py
  • git diff --check

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.

an emptied dotted-key captures the elements that follow it

1 participant