From cc1d1b8c6f777fb0aeec3bdddb6665a3f6f805d9 Mon Sep 17 00:00:00 2001 From: KotlinIsland Date: Sun, 11 Aug 2024 21:38:58 +1000 Subject: [PATCH] wip --- mypy/messages.py | 3 --- test-data/unit/check-functions.test | 2 +- test-data/unit/check-functools.test | 3 ++- test-data/unit/check-generics.test | 24 ++++++++++++------------ test-data/unit/check-inference.test | 2 +- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/mypy/messages.py b/mypy/messages.py index 41c6a859045a..4f236d0f8049 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -2686,9 +2686,6 @@ def format_literal_value(typ: LiteralType) -> str: return f"Unpack[{format(typ.type)}]" elif isinstance(typ, TypeVarType): # This is similar to non-generic instance types. - fullname = scoped_type_var_name(typ) - if verbosity >= 2 or (fullnames and fullname in fullnames): - return fullname if mypy.options._based and typ.scopename and typ not in disable_own_scope: return f"{typ.name}@{typ.scopename}" return typ.name diff --git a/test-data/unit/check-functions.test b/test-data/unit/check-functions.test index b399650fd71b..18f0f9d4262d 100644 --- a/test-data/unit/check-functions.test +++ b/test-data/unit/check-functions.test @@ -3343,7 +3343,7 @@ class C: # Note: Generic[T] missing self.x = x def nope(self, x: T) -> None: - self.x = x # E: Incompatible types in assignment (expression has type "T@nope", variable has type "T@bad_idea") + self.x = x # E: Incompatible types in assignment (expression has type "T", variable has type "T") [case testNoCrashOnBadCallablePropertyOverride] from typing import Callable, Union diff --git a/test-data/unit/check-functools.test b/test-data/unit/check-functools.test index 55946095c93f..29444ef8dd86 100644 --- a/test-data/unit/check-functools.test +++ b/test-data/unit/check-functools.test @@ -283,7 +283,8 @@ p1("a", "b") # TODO: false negative import functools from typing_extensions import TypeGuard -def is_str_list(val: list[object]) -> TypeGuard[list[str]]: ... # E: "list" is not subscriptable, use "typing.List" instead +def is_str_list(val: list[object]) -> TypeGuard[list[str]]: ... # E: "list" is not subscriptable, use "typing.List" instead \ + # E: "list" is not subscriptable, use "typing.List" instead reveal_type(functools.partial(is_str_list, [1, 2, 3])) # N: Revealed type is "functools.partial[builtins.bool]" reveal_type(functools.partial(is_str_list, [1, 2, 3])()) # N: Revealed type is "builtins.bool" diff --git a/test-data/unit/check-generics.test b/test-data/unit/check-generics.test index 71e0deaa3d35..7831753ade17 100644 --- a/test-data/unit/check-generics.test +++ b/test-data/unit/check-generics.test @@ -1612,17 +1612,17 @@ if int(): if int(): y1 = f3 if int(): - y1 = f4 # E: Incompatible types in assignment (expression has type "Callable[[int], A@f4]", variable has type "Callable[[A@f1], A@f1]") + y1 = f4 # E: Incompatible types in assignment (expression has type "Callable[[int], A]", variable has type "Callable[[A], A]") y2 = f2 if int(): y2 = f2 if int(): - y2 = f1 # E: Incompatible types in assignment (expression has type "Callable[[A@f1], A@f1]", variable has type "Callable[[A@f2], B]") + y2 = f1 # E: Incompatible types in assignment (expression has type "Callable[[A], A]", variable has type "Callable[[A], B]") if int(): - y2 = f3 # E: Incompatible types in assignment (expression has type "Callable[[B@f3], B@f3]", variable has type "Callable[[A], B@f2]") + y2 = f3 # E: Incompatible types in assignment (expression has type "Callable[[B], B]", variable has type "Callable[[A], B]") if int(): - y2 = f4 # E: Incompatible types in assignment (expression has type "Callable[[int], A@f4]", variable has type "Callable[[A@f2], B]") + y2 = f4 # E: Incompatible types in assignment (expression has type "Callable[[int], A]", variable has type "Callable[[A], B]") y3 = f3 if int(): @@ -1638,7 +1638,7 @@ y4 = f4 if int(): y4 = f4 if int(): - y4 = f1 # E: Incompatible types in assignment (expression has type "Callable[[A@f1], A@f1]", variable has type "Callable[[int], A@f4]") + y4 = f1 # E: Incompatible types in assignment (expression has type "Callable[[A], A]", variable has type "Callable[[int], A]") if int(): y4 = f2 if int(): @@ -1659,26 +1659,26 @@ def outer(t: T) -> None: y1 = f1 if int(): y1 = f2 - y1 = f3 # E: Incompatible types in assignment (expression has type "Callable[[T], A@f3]", variable has type "Callable[[A@f1], A@f1]") - y1 = f4 # E: Incompatible types in assignment (expression has type "Callable[[A@f4], T]", variable has type "Callable[[A@f1], A@f1]") + y1 = f3 # E: Incompatible types in assignment (expression has type "Callable[[T], A]", variable has type "Callable[[A], A]") + y1 = f4 # E: Incompatible types in assignment (expression has type "Callable[[A], T]", variable has type "Callable[[A], A]") y1 = f5 # E: Incompatible types in assignment (expression has type "Callable[[T], T]", variable has type "Callable[[A], A]") y2 = f2 if int(): - y2 = f1 # E: Incompatible types in assignment (expression has type "Callable[[A@f1], A@f1]", variable has type "Callable[[A@f2], B]") + y2 = f1 # E: Incompatible types in assignment (expression has type "Callable[[A], A]", variable has type "Callable[[A], B]") y3 = f3 if int(): - y3 = f1 # E: Incompatible types in assignment (expression has type "Callable[[A@f1], A@f1]", variable has type "Callable[[T], A@f3]") + y3 = f1 # E: Incompatible types in assignment (expression has type "Callable[[A], A]", variable has type "Callable[[T], A]") y3 = f2 - y3 = f4 # E: Incompatible types in assignment (expression has type "Callable[[A@f4], T]", variable has type "Callable[[T], A@f3]") + y3 = f4 # E: Incompatible types in assignment (expression has type "Callable[[A], T]", variable has type "Callable[[T], A]") y3 = f5 # E: Incompatible types in assignment (expression has type "Callable[[T], T]", variable has type "Callable[[T], A]") y4 = f4 if int(): - y4 = f1 # E: Incompatible types in assignment (expression has type "Callable[[A@f1], A@f1]", variable has type "Callable[[A@f4], T]") + y4 = f1 # E: Incompatible types in assignment (expression has type "Callable[[A], A]", variable has type "Callable[[A], T]") y4 = f2 - y4 = f3 # E: Incompatible types in assignment (expression has type "Callable[[T], A@f3]", variable has type "Callable[[A@f4], T]") + y4 = f3 # E: Incompatible types in assignment (expression has type "Callable[[T], A]", variable has type "Callable[[A], T]") y4 = f5 # E: Incompatible types in assignment (expression has type "Callable[[T], T]", variable has type "Callable[[A], T]") y5 = f5 diff --git a/test-data/unit/check-inference.test b/test-data/unit/check-inference.test index 18ad484baab7..1b6a7c48f040 100644 --- a/test-data/unit/check-inference.test +++ b/test-data/unit/check-inference.test @@ -988,7 +988,7 @@ a = k2 if int(): a = k2 if int(): - a = k1 # E: Incompatible types in assignment (expression has type "Callable[[int, List[T@k1]], List[Union[T@k1, int]]]", variable has type "Callable[[S, List[T@k2]], List[Union[T@k2, int]]]") + a = k1 # E: Incompatible types in assignment (expression has type "Callable[[int, List[T]], List[Union[T, int]]]", variable has type "Callable[[S, List[T]], List[Union[T, int]]]") b = k1 if int(): b = k1