Repository navigation
🐛 Make Library.remove atomic and tolerant of changed block keys - #607
Merged
Merged
Conversation
MiWeiss
force-pushed
the
fix/library-remove-changed-key
branch
3 times, most recently
from
September 2, 2026 20:00
488c802 to
99d5aa1
Compare
remove() deleted the block from _blocks before deleting it from the by-key dicts, and looked the dict entry up via block.key. A key changed after adding thus raised a raw KeyError (instead of the documented ValueError) and left the library half-modified. Removal now resolves the block index and its by-key registration (by identity, falling back to the key) before mutating anything, so failures leave the library unchanged and a list removal with a missing block is atomic, as in add(). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
MiWeiss
force-pushed
the
fix/library-remove-changed-key
branch
from
September 2, 2026 20:03
99d5aa1 to
51ba76a
Compare
Collaborator
Author
|
lgtm |
docstr-coverage requires a docstring on the nested helper; the hook is not part of the local test run, so CI caught it first. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
MiWeiss
force-pushed
the
fix/library-remove-changed-key
branch
from
September 2, 2026 20:38
b8f56b4 to
e06b1dd
Compare
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.
Library.removedeletes from_blocksbefore the key dicts. Keys are mutable, so a renamed block raisesKeyErrorafter it has already been dropped.The documented contract is
ValueError.replaceinherits this, and list removal was non-atomic.Fix: resolve all indices and key registrations first, mutate after. Registrations are found by identity, falling back to the key, so renames de-register correctly.
removeis now atomic, mirroringadd.Tests: 6 cases, 4 fail before. Suite 2582 passed, from 2576.
🤖 Generated with Claude Code