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
Thanks for submitting. Looks like there a few things not quite right with our tuple implementation.
Tuple validation doesn't respect argument order either:
importtypicfromtypingimportTupleproto=typic.protocol(Tuple[str, int])
proto.transmute((1, 1)) # ('1', '1') <-- should be ('1', 1)proto.validate(("foo", 1)) # ("foo", 1) <-- okayproto.validate((1, "foo")) # (1, 'foo') <-- should raise a validation errorproto.validate((1, "foo", "bar")) # (1, 'foo', 'bar') <-- should raise a validation error
I think this is inherent in the implementation, which treats tuple like just another iterable, when in fact the shape of a tuple is quite meaningful. If the tuple is unbounded in size (e.g., notated with an ellipsis), then yes, that is correct, but if the tuple is constrained in size, we should treat it more like we treat a class, TypedDict, or NamedTuple.
Description
Hey, @seandstewart
As title said, when transmute a tuple type with typed elements.
The second element type
int
is transmuted tostr
type.The text was updated successfully, but these errors were encountered: