MutableProxy: wrap dataclass and BaseModel methods#5979
Merged
Conversation
When calling a method on an arbitrary wrapped object, rebind it's `self` as the mutable proxy so changes made inside the method are also tracked. (Previously only wrapped `Base` instances had in-method tracking).
CodSpeed Performance ReportMerging #5979 will not alter performanceComparing Summary
|
Contributor
Greptile OverviewGreptile SummaryThis PR extends method wrapping in Key changes:
The logic transformation is correct and the test coverage is thorough. Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User as Event Handler
participant MP as MutableProxy
participant Obj as Wrapped Object (dataclass/BaseModel)
participant State as State Manager
User->>MP: Call method (e.g., obj.set_foo("val"))
MP->>MP: __getattr__("set_foo")
alt Method is callable with __func__
alt Not Base OR not in NEVER_WRAP_BASE_ATTRS
MP->>MP: Wrap with functools.partial(method.__func__, self)
MP->>MP: Apply _wrap_recursive_decorator
Note over MP: Rebind method's self to MutableProxy<br/>so changes are tracked
end
end
MP->>Obj: Execute method with proxy as self
Obj->>MP: self.foo = "val" (via proxy)
MP->>MP: __setattr__ triggered
MP->>State: Mark var as dirty
MP-->>User: Return method result
|
adhami3310
approved these changes
Nov 14, 2025
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.
When calling a method on an arbitrary wrapped object, rebind it's
selfas the mutable proxy so changes made inside the method are also tracked.(Previously only wrapped
Baseinstances had in-method tracking).