Whole file
python-poetry/tomlkit
The author described this change as “Fix top-level scalar captured by a table rendered from a dotted key (#550)”. It counts as a record because the check below fails on the code as it stood at 21a4942ed and passes on 495a42ecc, with nothing else changed between the two runs.
Projectpython-poetry/tomlkit
Fix saved2026-07-15
Sharing licenceMIT · LICENSE
Change size+24 −0
What the code was meant to do, written into the code itself as a save note
Fix top-level scalar captured by a table rendered from a dotted key (#550)
The change
| 161 | 161 | ||
| 162 | 162 | if isinstance(v, (Table, AoT)) and k is not None and not k.is_dotted(): | |
| 163 | 163 | break | |
| 164 | + | ||
| 165 | + | if ( | |
| 166 | + | isinstance(v, Table) | |
| 167 | + | and k is not None | |
| 168 | + | and k.is_dotted() | |
| 169 | + | and self._renders_table_header(v) | |
| 170 | + | ): | |
| 171 | + | # A dotted-key super table renders inline (`a.b = 1`) only as | |
| 172 | + | # long as none of its children render a `[table]` header; once | |
| 173 | + | # one does, anything appended after it would land inside that | |
| 174 | + | # table's scope. | |
| 175 | + | break | |
| 164 | 176 | last_index = i | |
| 165 | 177 | return last_index + 1 | |
| 178 | + | ||
| 179 | + | def _renders_table_header(self, table: Table) -> bool: | |
| 180 | + | for k, v in table.value.body: | |
| 181 | + | if isinstance(v, AoT): | |
| 182 | + | return True | |
| 183 | + | if isinstance(v, Table): | |
| 184 | + | if k is not None and k.is_dotted() and v.is_super_table(): | |
| 185 | + | if self._renders_table_header(v): | |
| 186 | + | return True | |
| 187 | + | else: | |
| 188 | + | return True | |
| 189 | + | return False | |
| 166 | 190 | ||
| 167 | 191 | def _validate_out_of_order_table(self, key: Key | None = None) -> None: | |
| 168 | 192 | if key is None: |
The check that tells the two apart
fail→pass·tests/test_toml_document.py::test_scalar_is_not_captured_by_table_rendered_from_dotted_key
Check file tests/test_toml_document.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it21a4942ed31e773061c9fc047d55b1bb3c637ee3
Broken version dated2026-07-14
Moduletomlkit.container
Units changedContainer
Fingerprint5904f13989c6a788
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in python-poetry/tomlkit
- 2026-07-14Fix array of tables replacing a dotted key swallowing the next sibling (#542) (#549)
- 2026-07-14fix: avoid duplicate table header when adding a key to an out-of-order table (#545)
- 2026-06-23fix: keep newline after dotted inline table (#533)
- 2026-06-23fix: reject out-of-order concrete+super table redefinitions at parse time (#530)
- 2026-06-23raise on malformed array element instead of dropping it (#527)
- 2026-06-23Fix ParseError when a sub-table extends an array of tables out of order (#498)