fix(api): prevent protocols from passing with mistyped property setting for liquid classes #17258
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
This PR addresses an issue found while testing liquid classes. The API for changing individual liquid class properties uses the
@property.setter
decorator to allow easy one line changes of properties while validating the values that the properties are being set to. A consequence of this is because Python allows dynamic setting of variables, a typo (e.g puttingwater_p50_props.aspirate.mix.enable = True
instead ofwater_p50_props.aspirate.mix.enabled = True
) did not cause the protocol to fail analysis. This means that a multi-hour protocol could not behave as expected due to a typo somewhere in the protocol.Since this would be a huge pain point for customers, the liquid class properties now use the
slots=True
argument of dataclass to automatically generate the__slots__
attribute, preventing instances from being assigned new variables while giving a small, though negligible, performance boost.Test Plan and Hands on Testing
This protocol now fails analysis with a
AttributeError [line 16]: 'MixProperties' object has no attribute 'enable'
error. Fixing line 16 to be enabled causes the protocol to correctly pass.Changelog
Risk assessment
Low