We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
collections.abc.Callable
_SpecialForm
Typeshed currently treats collections.abc.Callable as equivalent to typing.Callable, but they aren't
typing.Callable
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.
ABCMeta
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)
The text was updated successfully, but these errors were encountered:
Possibly a duplicate of #6257?
Sorry, something went wrong.
Callable is indeed a special form in the type system (https://typing.readthedocs.io/en/latest/spec/annotations.html#expression-grammar). As such, type checkers need to special case it. Mypy here may not be special casing it correctly, but that's a bug in mypy, not typeshed.
Callable
If you have a concrete proposal for a change to typeshed that would help mypy here, we can consider it, but so far I don't see any.
No branches or pull requests
Typeshed currently treats
collections.abc.Callable
as equivalent totyping.Callable
, but they aren'tThis causes a very annoying bug: python/mypy#14014
collections.abc.Callable
is a subclass ofABCMeta
:, a real type that can be used in match-case and isinstance/issubclass.The text was updated successfully, but these errors were encountered: