Wednesday, May 17, 2023

Python generic types, new syntax

 PEP 695 – Type Parameter Syntax | peps.python.org

This PEP specifies an improved syntax for specifying type parameters within a generic class, function, or type alias. It also introduces a new statement for declaring type aliases.

Author: Eric Traut <erictr at microsoft.com>
Sponsor: Guido van Rossum <guido at python.org>

class ClassA[T: str]:
    def method1(self) -> T:
def func[T](a: T, b: T) -> T: