给定一个基类,如(伪编码):
class A():
def has_permission(self, *args, **kwargs):
action = getattr(self, 'can_view')
if callable(action):
return action(*args, **kwargs)
return action
def can_view(self, *args, **kwargs):
return False
和子类如:
class B(A):
can_view = True
如何输入提示?
Mypy引发了这个错误:
Incompatible types in assignment (expression has type "bool", base class "A" defined the type as "Callable[]")
我真的不知道该怎么做。