Repository navigation
Preserve proxy set operations and relation assignments - #58
Merged
HexDecimal merged 2 commits intoOct 13, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #58 +/- ##
=======================================
Coverage 99.15% 99.16%
=======================================
Files 9 9
Lines 949 956 +7
=======================================
+ Hits 941 948 +7
Misses 8 8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
HexDecimal
requested changes
Oct 13, 2026
HexDecimal
left a comment
Owner
There was a problem hiding this comment.
I forget if I've heard about the _from_iterable classmethod before now. Luckily the entity attribute assignments are more for completeness than as a primary method of interacting with them. Still, it's really good to have this fix.
The code and tests are good, but what's fixed needs to be noted in the changelog. I can do that if you don't.
HexDecimal
force-pushed
the
fix/retain-inplace-relation-updates
branch
from
October 13, 2026 07:23
8937954 to
3ba212d
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.
An in-place update of a relation set is written back to
EntityRelations.__setitem__. That setter clears the targets before iterating its argument, so a live view of those same targets is now empty:Currently this prints
[]; it should print['first', 'second', 'third']. Materialize the input iterable before clearing the old targets, which also handles lazy iterators over the same relation view.The inherited binary set operations have a related constructor problem: their default factory tries to construct an entity-bound proxy from only an iterable. Provide a plain-set factory for both
EntityTagsandEntityRelationsMapping. Binary operations then return independent sets, and&=can compute its removal set without raisingTypeError.Regression checks cover all four in-place relation operators, cached queries, a lazy self-view, copying another relation key, non-mutating binary operations and tag intersection. Seven checks fail before the change; the separate-key assignment control already passes. The full pytest/doctest suite, mypy and project-pinned Ruff checks pass, with the same baseline xpasses and warning.
Nine native 80-turn party-selection runs are compared with plain Python sets and cached forward/reverse queries. The change removes 687 wrong turn states and 180 operator exceptions; all corrected histories match direct assignment. Nine direct-assignment controls retain identical histories across all 720 turns. This check validates game-state bookkeeping, without claiming performance or gameplay quality improvements.