-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added check for classes that have mutually-incompatible base classes …
…due to generic type argument mismatches. This addresses #5748. (#5762) Co-authored-by: Eric Traut <[email protected]>
- Loading branch information
1 parent
b9f4615
commit bd54869
Showing
6 changed files
with
159 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This sample tests the detection of mutually-incompatible base classes | ||
# in classes that use multiple inheritance. | ||
|
||
from typing import Collection, Mapping, Sequence, TypeVar | ||
|
||
|
||
# This should generate an error. | ||
class A(Mapping[str, int], Collection[int]): | ||
... | ||
|
||
|
||
# This should generate an error. | ||
class B(Mapping[str, int], Sequence[int]): | ||
... | ||
|
||
|
||
# This should generate an error. | ||
class C(Sequence[int], Mapping[str, int]): | ||
... | ||
|
||
|
||
class D(Sequence[float], Mapping[float, int]): | ||
... | ||
|
||
|
||
class E(Sequence[float], Mapping[int, int]): | ||
... | ||
|
||
|
||
# This should generate an error. | ||
class F(Mapping[int, int], Sequence[float]): | ||
... | ||
|
||
|
||
T = TypeVar("T") | ||
S = TypeVar("S") | ||
|
||
|
||
class G(Mapping[T, S], Collection[T]): | ||
... | ||
|
||
|
||
# This should generate an error. | ||
class H(Mapping[T, S], Collection[S]): | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters