PEP695로 3.12부터 적용될 사항인데

기존에는 TypeVar로 제네릭 변수 지정해서 다음과 같이 사용했다면

from typing import Generic, TypeVar _T_co = TypeVar("_T_co", covariant=True, bound=str) class ClassA(Generic[_T_co]): def method1(self) -> _T_co: ...

이제는 이렇게 할 수 있음

class ClassA[T: str]: def method1(self) -> T: ...

별칭도 기존에는 이렇게 해야했다면

from typing import TypeAlias _T = TypeVar("_T") ListOrSet: TypeAlias = list[_T] | set[_T]

이제는 이렇게 할 수 있음

type ListOrSet[T] = list[T] | set[T]


아직 hkt지원은 없지만

요구하는 사람이 점점 많아지니까 시간문제일듯