types.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:magic-constraints 作者: huntzhan 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号