Skip to content

Commit

Permalink
Mandate error on inconsistent type variable order.
Browse files Browse the repository at this point in the history
  • Loading branch information
rchen152 committed Nov 2, 2024
1 parent 6ac3196 commit 057f9bf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/spec/generics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 057f9bf

Please sign in to comment.