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
This is not a priority, but probably we could allow subclassing Callable, some people might find this "nicer", than defining a __call__ method (e.g. if this is an ABC or a protocol). For example this already works at runtime:
classC(Callable[[int], int]):
attr: str
This would be implemented by returning CallableType for C with a fallback to an instance of the original TypeInfo (like for tulpes, see also #3831).
Reacted by Aleksei Stepanov, José Alfredo Romero L., Chad Dombrova, Johannes Baiter, stephane-2 and Felipe S. S. Schneider
Activity
msullivan commentedon Jan 28, 2020
The protocol thing works fine
bfontaine commentedon Feb 14, 2024
Why was this closed? Protocols are not sufficient because they don’t inherit callable properties like
__name__or__doc__:This fails with mypy 1.8.0: