def requires_bop(func) -> 'typing.Callable[[BaseOperator, BaseOperator], typing.Any]':
"""
A decorator that marks a magic method as requiring another BaseOperator.
:param func: The function to decorate.
:return: A function that returns NotImplemented when the class required isn't specified.
"""
@functools.wraps(func)
def inner(self, other: 'BaseOperator'):
if not isinstance(other, BaseOperator):
return NotImplemented
return func(self, other)
return inner
评论列表
文章目录