-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Output distinct types when type names are ambiguous (#15184)
Fixes #12677 When assert_type fails, when the type of value examined and the specified type have the same name, mypy returns an error with more descriptive and distinct names.
- Loading branch information
1 parent
13f35ad
commit a8bd273
Showing
2 changed files
with
30 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[case testAssertTypeFail1] | ||
import typing | ||
import array as arr | ||
class array: | ||
pass | ||
def f(si: arr.array[int]): | ||
typing.assert_type(si, array) # E: Expression is of type "array.array[int]", not "__main__.array" | ||
[builtins fixtures/tuple.pyi] | ||
|
||
[case testAssertTypeFail2] | ||
import typing | ||
import array as arr | ||
class array: | ||
class array: | ||
i = 1 | ||
def f(si: arr.array[int]): | ||
typing.assert_type(si, array.array) # E: Expression is of type "array.array[int]", not "__main__.array.array" | ||
[builtins fixtures/tuple.pyi] | ||
|
||
[case testAssertTypeFail3] | ||
import typing | ||
import array as arr | ||
class array: | ||
class array: | ||
i = 1 | ||
def f(si: arr.array[int]): | ||
typing.assert_type(si, int) # E: Expression is of type "array[int]", not "int" | ||
[builtins fixtures/tuple.pyi] |