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)
评论列表
文章目录