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
If a class with __call__ can be a subtype of Callable (#3132 implements this behavior), the fallback of Callable types should probably be object. For function objects defined using def, it's perhaps still fine to use a different callback.
Additionally, callable protocol members should probably all have a object as the fallback, even those defined using def. A concrete subtype of a protocol could implement a method using an instance of a user-defined class with __call__, which could effectively have an arbitrary fallback type.
It looks like we could use fallbacks to relatively easily allow subclassing Callable (same as for NamedTuples and TypedDicts), see discussion in #2087. Note that this already correctly works at runtime.
If a class with
__call__
can be a subtype ofCallable
(#3132 implements this behavior), the fallback ofCallable
types should probably beobject
. For function objects defined usingdef
, it's perhaps still fine to use a different callback.Additionally, callable protocol members should probably all have a
object
as the fallback, even those defined usingdef
. A concrete subtype of a protocol could implement a method using an instance of a user-defined class with__call__
, which could effectively have an arbitrary fallback type.More discussion: #3132 (comment)
cc @ilevkivskyi
The text was updated successfully, but these errors were encountered: