报告 PEP 695 类型形参语法的无效用法

在函数和类定义以及新样式类型别名语句中查找以下问题:

示例:


from typing import Generic

class Example[T](Generic[T]): ... # 带有类型形参列表的类不应扩展 'Generic'

class Example[T: (list[S], str)]: ... # 在类型形参的约束和边界内不允许使用泛型类型

from typing import TypeVar

  K = TypeVar("K")

  class ClassC[V]:
      def method2[M](self, a: M, b: K) -> M | K: ... # 不允许混合使用传统和新样式 TypeVars