Repository navigation
Synchronize TOML arrays after in-place repetition - #647
Open
harbinresearcher wants to merge 1 commit into
Open
harbinresearcher wants to merge 1 commit into
harbinresearcher wants to merge 1 commit into
Conversation
Wkhanex
reviewed
Oct 13, 2026
There was a problem hiding this comment.
21 standalone repetition checks passed for empty, numeric, multiline-commented and nested arrays, using counts -2, 0, 1, 2 and a custom object implementing __index__ (returning 3). I used Python 3.12.14 against commit 5d0b182.
For each case I checked that a *= count kept the array identity, its list values matched ordinary list repetition, and tomllib.loads(tomlkit.dumps(doc))["x"] matched those values. A float count raised TypeError and left serialization unchanged. The custom-index and invalid-count nonmutation cases are useful safeguards for the new operator.index call. I used fetched PR source; I did not run the full pytest suite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #646.
Array *= ncurrently changes its Python values but leaves serialized TOML unchanged. For example, multiplying[1, 2]by zero clears the array in memory while the saved document still contains[1, 2].Implement in-place repetition through the existing
clear()andextend()paths. Convert the repetition count before taking the values snapshot, preserving native-list behavior when__index__has side effects. Existing array identity and original formatting are retained; added repetitions use normal append formatting. No sorting, slice-assignment, dependency or public API changes.Testing:
__index__including mutation, invalid count and overflow, subsequent indexed mutation.Known baseline failures: Mypy 1.19.1 reports the same 29 diagnostics before and after (including the toml-test generator). Strict Sphinx builds using docs/requirements.txt fail on the same existing register_encoder docstring indentation in both baseline and patched sources. These checks are not claimed as passing.
Agent Drafting Metadata
Remote CI: all 18 platform tests and pre-commit.ci passed; five of six integration jobs passed. Ubuntu Poetry integration fails in the existing
test_extractall_sdist_no_symlink_path_traversal_via_directory_symlink(1 failed, 3,309 passed). Extracting the unchanged downstreamextractallfunction at Poetry commit63bba274f8ea6bc9a064f5328fa6c67bce617cc1and running the same archive scenario on Linux CPython 3.12.15 reproduces the missing expected exception without importing tomlkit or poetry.core. The file remains inside the destination. This is an isolated reproduction, not a full downstream baseline run.