types.py 文件源码

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

项目:magic-constraints 作者: huntzhan 项目源码 文件源码
def _class___new__(cls, instance):
        # 1. not Callable.
        if not isinstance(instance, cls.main_cls):
            raise MagicTypeError(
                'instance should be a Callable.',
                instance=instance,
            )
        # 2. with no specification.
        if not cls.partial_cls:
            raise MagicSyntaxError(
                'Callable should be specified to wrap the callable.',
            )

        parameters_types, return_type = cls.partial_cls

        if parameters_types is Ellipsis:
            parameters_types = [parameters_types]

        return function_constraints(
            *parameters_types,
            # tailing coma is invalid for version < 3.5.
            return_type=return_type
        )(instance)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号