From 057f9bfa38affd7fc6a4b109a27c82140d3cd96a Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Sat, 2 Nov 2024 12:03:28 -0700 Subject: [PATCH] Mandate error on inconsistent type variable order. --- docs/spec/generics.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/spec/generics.rst b/docs/spec/generics.rst index ecfc209b..7ad83384 100644 --- a/docs/spec/generics.rst +++ b/docs/spec/generics.rst @@ -509,7 +509,8 @@ That ``Child`` definition is equivalent to:: class Child(Parent1[T1, T3], Parent2[T2, T3], Generic[T1, T3, T2]): ... -Type checkers may warn when the type variable order is inconsistent:: +A type checker should report an error when the type variable order is +inconsistent:: from typing import Generic, TypeVar @@ -521,7 +522,7 @@ Type checkers may warn when the type variable order is inconsistent:: ... class Parent(Grandparent[T1, T2]): ... - class Child(Parent[T1, T2], Grandparent[T2, T1]): # Inconsistent order + class Child(Parent[T1, T2], Grandparent[T2, T1]): # INVALID ... Abstract generic types