def _class___init__(self, iterator):
if self.partial_cls is None:
raise MagicTypeError(
'Iterator should be specified.'
)
if not isinstance(iterator, self.main_cls):
raise MagicTypeError(
'require Iterator.',
iterator=iterator,
)
if isinstance(self.partial_cls, tuple):
# Iterator[T, ...]. Checking on:
# 1. the number of elements in the iterator.
# 2. the type of each element.
self.case = self.ITERATOR_CASE_LENGTH
self._type_idx = 0
else:
# Iterator[T]. Check only the type of element. There's no
# limitation on the length of iterator.
self.case = self.ITERATOR_CASE_NO_LENGTH
self.iterator = iterator
评论列表
文章目录