Repository navigation
fix(abstractions): subscribe list items once and keep list sizes fresh in the backing store - #802
Open
Max Azatian (HardMax71) wants to merge 2 commits into
Conversation
…ore bugs it shows Annotate the rest of kiota_abstractions.store and default the BackingStore and InMemoryBackingStore type parameters to object, like RequestAdapter and ParsableFactory, so generated models that declare a bare `backing_store: BackingStore` still pass mypy --strict. BackingStoreFactorySingleton was never a singleton. `hasattr(cls, "__instance")` checks the unmangled name, so every call built a new instance and assigned the factory over the `backing_store_factory` property on the class, and a call with None put back a fresh InMemoryBackingStoreFactory. Generated models call it with None at import, so a factory passed to enable_backing_store never stuck. It now keeps one instance, None keeps the current factory, and a factory replaces it. InMemoryBackingStore stored lists as a (list, size) tuple and get() unwrapped any tuple, so a stored tuple such as (1, 2) came back as 1. Entries now keep the value and the list's size side by side, so get() returns what was set. enumerate_() still returns the (list, size) pair for lists. Subscribers now get the previous and new values, as subscribe documents, instead of the internal entries. Part of microsoft#722.
| item.backing_store.is_initialization_completed = True | ||
| item.backing_store.subscribe( | ||
| lambda prop_key, old_val, new_val: self.set(key, value) | ||
| lambda prop_key, old_val, new_val: self.set(key, value), key |
Contributor
Author
There was a problem hiding this comment.
haven't thought about it tbh, fixed in 723f291
…h in the backing store Each time a list was set, every BackedModel in it got one more subscription. The callback sets the list again, so each change to an item doubled its subscriptions. Items now subscribe under the store's own id plus the property name. A repeat subscription from the same store replaces the old one, and a child shared by two stores still notifies both. The is_initialization_completed setter saved the entry it read before the size check. A list that had grown was saved with its old size and showed up as changed again on the next enumerate_. It now saves the entry after the check, as the C# store does.
Max Azatian (HardMax71)
force-pushed
the
fix/backing-store-subscriptions-and-sizes
branch
from
October 14, 2026 19:25
7c50a5b to
723f291
Compare
|
This branch has not been deployed
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.




Overview
Two more backing store bugs, found while typing the store in #800. This branch builds on #800, so until that merges the diff also shows its commit. The change here is only the last commit, 723f291.
BackedModelin it one more subscription. Each one sets the list again, so every change to an item doubled its subscriptions, 256 after 8 changes. Items now subscribe under the store's own id plus the property name. A repeat subscription from the same store replaces the old one, and a child shared by two stores still notifies both.is_initialization_completedsetter saved the entry it read before the size check. A list that had grown was saved with its old size and showed up as changed right after. It now saves the entry after the check, like the C# store.Related Issue
Follow-up to #800, found while working on #722.
Testing Instructions
pytestinpackages/abstractionspasses.test_list_items_notify_the_store_once_per_changeandtest_completing_initialization_clears_a_resized_listfail.test_list_item_shared_by_two_stores_notifies_bothcovers a child shared by two stores.