You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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): ...
The text was updated successfully, but these errors were encountered:
It is not possible to satisfy an ABC that has an Optional Callable with args defined using a "def" in the concrete class.
A Callable which is not optional may be defined.
An Optional Callable with no arguments may also be defined.
Reproduction of the problem using mypy version 0.961 in the mypy playground.
The cases
Two
andThree
below should be accepted as suitable implementations ofcheck
, and they are not.The text was updated successfully, but these errors were encountered: