Repository navigation
Fix reverse slice mutations in ObservableList - #3962
Merged
Merged
Conversation
Contributor
Author
|
The The branch is current with |
|
Performance benchmarks:
|
quaquel
approved these changes
Oct 22, 2026
EwoutH
pushed a commit
that referenced
this pull request
Oct 28, 2026
(cherry picked from commit 093e967)
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.
Pre-PR Checklist
Summary
Make negative-step slice assignment and deletion on
ObservableListfollow Python list semantics. For example,items[::-1] = [4, 5, 6]on a three-element list currently raises, whiledel items[::-1]silently leaves the list unchanged.Bug / Issue
Fixes #3961.
Implementation
Use the original slice to read and mutate the underlying list. Keep normalized bounds for the signal's
indexfield. Reconstructing a slice fromslice.indices()reinterprets its-1stop sentinel as an index relative to the end, which turns full reverse slices into empty slices.Testing
pytest --durations=10 tests/ -Werror -Wdefault::PendingDeprecationWarning, 896 passed on Python 3.12.11 and macOS, including browser tests.The 17 added cases produced 11 failures and 6 passes against unchanged main. They cover reverse and strided replacement/deletion, clipped and empty slices, replacement iterators, invalid replacement lengths, and batched notifications. The unchanged full suite passed all 879 tests.
Additional Notes
Signal index normalization remains unchanged.
All six CI test-matrix jobs pass (Linux Python 3.12, 3.13, 3.14, prerelease dependencies; Windows and macOS Python 3.14), along with coverage and pre-commit. The separate
mesa-examplesjob fails on an outdatedmesa.meta_agentsimport, matching the failure on unchanged main.