List[uint64] is not like a type but just for annotation, same for other Generics with __args__, Vector/BytesN work, because their metaclasses produce non-parametrized types, so don't check vector values when type contains args

This commit is contained in:
protolambda 2019-06-05 18:53:34 +02:00
parent 1cc7c7309d
commit b9abc5f2cf
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
1 changed files with 2 additions and 2 deletions

View File

@ -246,8 +246,8 @@ class Vector(metaclass=VectorMeta):
self.items = list(args)
# cannot check non-type objects
if isinstance(cls.elem_type, type):
# cannot check non-type objects, or parametrized types
if isinstance(cls.elem_type, type) and not hasattr(cls.elem_type, '__args__'):
for i, item in enumerate(self.items):
if not issubclass(type(item), cls.elem_type):
raise TypeError("Typed vector cannot hold differently typed value"