File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -2504,3 +2504,23 @@ b: I[I[Any]]
2504
2504
reveal_type([a, b]) # N: Revealed type is "builtins.list[__main__.I[__main__.I[Any]]]"
2505
2505
reveal_type([b, a]) # N: Revealed type is "builtins.list[__main__.I[__main__.I[Any]]]"
2506
2506
[builtins fixtures/list.pyi]
2507
+
2508
+ [case testOverlappingTypeVarIds]
2509
+ from typing import TypeVar, Generic
2510
+
2511
+ class A: ...
2512
+ class B: ...
2513
+
2514
+ T = TypeVar("T", bound=A)
2515
+ V = TypeVar("V", bound=B)
2516
+ S = TypeVar("S")
2517
+
2518
+ class Whatever(Generic[T]):
2519
+ def something(self: S) -> S:
2520
+ return self
2521
+
2522
+ # the "V" here had the same id as "T" and so mypy used to think it could expand one into another.
2523
+ # this test is here to make sure that doesn't happen!
2524
+ class WhateverPartTwo(Whatever[A], Generic[V]):
2525
+ def something(self: S) -> S:
2526
+ return self
You can’t perform that action at this time.
0 commit comments