fix for typing check of vector elements with non-type element type (annotation)

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

View File

@ -1,4 +1,3 @@
from inspect import isclass
from typing import List, Iterable, TypeVar, Type, NewType from typing import List, Iterable, TypeVar, Type, NewType
from typing import Union from typing import Union
from typing_inspect import get_origin from typing_inspect import get_origin
@ -247,8 +246,8 @@ class Vector(metaclass=VectorMeta):
self.items = list(args) self.items = list(args)
# cannot check non-class objects # cannot check non-type objects
if isclass(cls.elem_type): if isinstance(cls.elem_type, type):
for i, item in enumerate(self.items): for i, item in enumerate(self.items):
if not isinstance(item, cls.elem_type): if not isinstance(item, cls.elem_type):
raise TypeError("Typed vector cannot hold differently typed value" raise TypeError("Typed vector cannot hold differently typed value"