The cases Two and Three below should be accepted as suitable implementations of check, and they are not.
import abc
from typing import Callable, Optional
# optional callable with an argument define
class OptCallArgs(abc.ABC):
check: Optional[Callable[[int], None]]
# assignment of a callable is fine
class One(OptCallArgs):
check = lambda value: None
# "def" of a suitable callable is not handled
class Two(OptCallArgs):
@staticmethod
def check(value: int): ...
class Three(OptCallArgs):
def check(self, value: int): ...
# callable with args has no issue
class CallArgs(abc.ABC):
check: Callable[[int], None]
class Four(CallArgs):
def check(self, value: int): ...
# optional callable does not have an issue if there are no args
class OptCall(abc.ABC):
check: Optional[Callable]
class Five(OptCall):
def check(self): ...
Activity
Use checkmember.py to check variable overrides (python#18847)