PEP 718
A Python Enhancement Proposal: explicit type parameters for generic functions.
A Python Enhancement Proposal I co-authored with James Hilton-Balfe, sponsored by Guido van Rossum, the creator of Python. A PEP is how changes to the Python language are proposed and discussed. This one makes functions subscriptable, so a generic function can be given its type parameters explicitly, the same way a generic class can:
def my_list[T](arr: Iterable[T]) -> list[T]: ...
my_list[int]() # today: TypeError
This helps where type inference can't work out the type, keeps functions and classes consistent, and leaves room for future features like monomorphisation. Status: Draft, targeting Python 3.15.