You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Structure raw data into an instance of a class, in such a way that container type is respected.
What I Did
>>>@define
... classC:
... a: int
... b: set[str]
...
>>>instance=structure({'a': 1, 'b': ['x', 'y']}, C)
>>>instanceC(a=1, b={'x', 'y'})
What I Expect
I expect a failure, since the list[str] value for the b key doesn't conform to the set[str] type of the corresponding member of the class. This violates separation of concerns: the structure call is also deduplicating elements of the list, then, for the conversion to a set. As such, a reasonable invariant like "each collections in the raw data should have the same size as the corresponding collection once structured into the class" can be violated.
The text was updated successfully, but these errors were encountered:
Description
Structure raw data into an instance of a class, in such a way that container type is respected.
What I Did
What I Expect
I expect a failure, since the
list[str]
value for theb
key doesn't conform to theset[str]
type of the corresponding member of the class. This violates separation of concerns: thestructure
call is also deduplicating elements of the list, then, for the conversion to a set. As such, a reasonable invariant like "each collections in the raw data should have the same size as the corresponding collection once structured into the class" can be violated.The text was updated successfully, but these errors were encountered: