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
I'd like to make both instances and the types of functions and methods (including builtin methods) subscriptable.
Part of this proposal has been discussed already on python-ideas (https://discuss.python.org/t/making-functions-subscriptable-at-runtime/26463) but I thought it might also be worthwhile making FunctionType etc. subscriptable and work in a similar way to Callable just with extra descriptor behaviour that binds it into a MethodType.
classFoo:
bar: FunctionType[[Self, int], str]
# equivalent to defbar(self, arg1, /) ->str: ...
This is different from Callable as if FunctionType was replaced with Callable, bar would always require a self argument.
This unfortunately probably requires special casing in type checkers as it isn't quite currently possible with PEP 612 (ParamSpec + Concatenate) (see #946) unless the PEP is updated
The text was updated successfully, but these errors were encountered:
I'd like to make both instances and the types of functions and methods (including builtin methods) subscriptable.
Part of this proposal has been discussed already on python-ideas (https://discuss.python.org/t/making-functions-subscriptable-at-runtime/26463) but I thought it might also be worthwhile making
FunctionType
etc. subscriptable and work in a similar way toCallable
just with extra descriptor behaviour that binds it into aMethodType
.This is different from
Callable
as ifFunctionType
was replaced withCallable
,bar
would always require a self argument.This unfortunately probably requires special casing in type checkers as it isn't quite currently possible with PEP 612 (ParamSpec + Concatenate) (see #946) unless the PEP is updated
The text was updated successfully, but these errors were encountered: