Closed as not planned
Description
Typeshed currently treats collections.abc.Callable
as equivalent to typing.Callable
, but they aren't
import typing
from collections import abc
assert isinstance(abc.Callable, type) # ✅
assert isinstance(typing.Callable, type) # ❌
This causes a very annoying bug: python/mypy#14014
collections.abc.Callable
is a subclass of ABCMeta
:, a real type that can be used in match-case and isinstance/issubclass.
class Callable(metaclass=ABCMeta):
__slots__ = ()
@abstractmethod
def __call__(self, *args, **kwds):
return False
@classmethod
def __subclasshook__(cls, C):
if cls is Callable:
return _check_methods(C, "__call__")
return NotImplemented
__class_getitem__ = classmethod(_CallableGenericAlias)
Metadata
Metadata
Assignees
Labels
No labels