Skip to content

Synchronize TOML arrays after in-place repetition - #647

Open
harbinresearcher wants to merge 1 commit into
python-poetry:masterfrom
harbinresearcher:codex/sync-array-inplace-repeat
Open

harbinresearcher wants to merge 1 commit into
python-poetry:masterfrom
harbinresearcher:codex/sync-array-inplace-repeat

Conversation

@harbinresearcher

@harbinresearcher harbinresearcher commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary

Closes #646.

Array *= n currently 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() and extend() 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:

  • Ten regression cases: positive/zero/negative repetition, original hexadecimal spelling and comments, no-op/empty arrays, custom __index__ including mutation, invalid count and overflow, subsequent indexed mutation.
  • Pristine-master RED: 6 failed, 4 passed. Patched regressions: all passed.
  • Full suites with required toml-test submodule: Windows Python 3.9/3.12 and Linux Python 3.12 each 1,107 passed (baseline 1,097).
  • Pinned pre-commit hooks: all passed. Local runner upgraded separately because the declared pre-commit 2.x cannot read the pinned hooks' current stage names; repository dependencies were not changed.
  • Source distribution and wheel built from it: passed.

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

  • Agent: OpenAI Codex
  • Model: GPT-6
  • Notes: AI assisted investigation, implementation, regression testing, read-only review and documentation. Local test results are reported above; no maintainer approval or production usage is claimed.

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 downstream extractall function at Poetry commit 63bba274f8ea6bc9a064f5328fa6c67bce617cc1 and 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.

@Wkhanex Wkhanex left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

In-place array repetition changes values without updating serialized TOML

2 participants