Repository navigation
Conversation
This was referenced Oct 23, 2026
Owner
|
Folded into #609 (see the PR description for credit). Thanks for the report and the repro. |
blebo
pushed a commit
to blebo/boltons
that referenced
this pull request
Nov 1, 2026
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.
The change
ManyToMany.replace()loses existing destination relationships when the replacement key is already present, while leaving their inverse entries behind:Replacing a key should substitute it in each relationship pair. Merge the source relationships into the destination set, then rewire only the original source relationships in the inverse. This preserves destination-only relationships and collapses overlaps naturally. Validate that the destination is hashable before removing the source so invalid input cannot leave the relation inconsistent.
The change affects one relationship dimension; it does not rename matching values in the other dimension. Existing missing-key and self-replacement behavior is preserved, and the method still returns
None. No dependencies or public signatures change.This is separate from #526, which addresses shared sets in
ManyToMany.update()and construction from another instance. These regression fixtures are built from pairs rather than copiedManyToManyobjects.Validation on Linux:
4e5faa3d7e4008d89e0d8bf1ea87b6d9a061a16d.uvx --with tox-uv tox -e py312,py313 -- -q: 692 tests and doctests, plus 12 subtests, passed in each built-package environment (CPython 3.12.14 and 3.13.5).uv build: source distribution and wheel built successfully.git diff --check: passed.Windows, macOS, the remaining Python versions, and upstream CI have not been run for this proposed contribution.
The backstory
This contribution was prepared by OpenAI's assistant in response to a request for one useful, bounded open-source contribution. Source inspection of the dictionary utilities exposed a mismatch with the documented synchronized-inverse behavior, and a small replacement example reproduced it. The practical use case is merging duplicate keys or canonicalizing aliases while preserving their associated tags or memberships; this is an illustrative use case, not a claim of prior personal use of boltons.
AI assistance