-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(api): Allow recovering from errors that happen during the preparation part of an aspirate command #16896
Changes from 3 commits
76b3dcf
9c73832
41e91d8
65a6d46
2b71df4
d64f7fb
0882fef
9137ec2
3d8d9ae
3d93931
253d082
d8d234a
463f34f
d6813ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,6 +299,19 @@ class StateUpdate: | |
|
||
liquid_class_loaded: LiquidClassLoadedUpdate | NoChangeType = NO_CHANGE | ||
|
||
def append(self, other: Self) -> Self: | ||
"""Apply another `StateUpdate` "on top of" this one. | ||
|
||
This object is mutated in-place, taking values from `other`. | ||
If an attribute in `other` is `NO_CHANGE`, the value in this object is kept. | ||
""" | ||
fields = dataclasses.fields(other) | ||
for field in fields: | ||
other_value = other.__dict__[field.name] | ||
if other_value != NO_CHANGE: | ||
self.__dict__[field.name] = other_value | ||
return self | ||
|
||
Comment on lines
+302
to
+314
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could make this |
||
@classmethod | ||
def reduce(cls: typing.Type[Self], *args: Self) -> Self: | ||
"""Fuse multiple state updates into a single one. | ||
SyntaxColoring marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo passthrough and union with previous successes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've settled on ignoring
state_update_if_false_positive
until/unless this command actually uses it for something, in which case the right thing to do will hopefully be more obvious.The reason I'm not setting up a pattern of "passthrough and union with previous successes" (yet) is just uncertainty on my part. Like, it kind of smells to me like an
Implementation.execute()
concern that our inner helper functions aren't in a good position to anticipate. And I wouldn't want to go out of our way to set up a pattern that does nothing now and starts doing the wrong thing later on.