Description
With #16804 completed, we have the necessary infrastructure to check subtype/assignability relationship between two callable objects. Currently, it only does the check for subtyping/assignability between two GeneralCallableType
types, which effectively means typing.Callable
annotation or lambdas, as those are the only things that construct the GeneralCallableType
. (We do expose knot_extensions.CallableTypeFromFunction
from knot_extensions
which converts a FunctionType
into a GeneralCallableType
but that's mainly to help write tests for it.)
This issue is to check other subtype and assignability relationships involving callable objects that still need to be implemented:
- A
CallableType
is always a subtype ofKnownClass::Object
(and never the other way around) - A
FunctionType
can be a subtype ofCallable
(but never the other way around) - Other (non-
GeneralCallable
)Type::Callable
variants, like bound methods, can be subtypes of / assignable toCallable
s. -
InstanceType (with a __call__ method)
can be a subtype ofCallable
(but never the other way around)