From b9abc5f2cf349cf0ec211458df36b86b92b42edf Mon Sep 17 00:00:00 2001 From: protolambda Date: Wed, 5 Jun 2019 18:53:34 +0200 Subject: [PATCH] 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 --- test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py b/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py index 4944fb600..368041f90 100644 --- a/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py +++ b/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py @@ -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"