Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinIsland committed Aug 11, 2024
1 parent e58efb7 commit cc1d1b8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
3 changes: 0 additions & 3 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-functions.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test-data/unit/check-functools.test
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 12 additions & 12 deletions test-data/unit/check-generics.test
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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():
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-inference.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cc1d1b8

Please sign in to comment.