@@ -880,7 +880,7 @@ from typing_extensions import reveal_type
880880def _ (a : int | None ):
881881 reveal_type(
882882 # error: [no-matching-overload]
883- # revealed: Any
883+ # revealed: Unknown
884884 f(
885885 A(),
886886 a1 = a,
@@ -1231,8 +1231,8 @@ def _(list_int: list[int], list_any: list[Any]):
12311231 # All materializations of `list[Any]` are assignable to `list[int]` and `list[Any]`, but the
12321232 # return type of first and second overloads are not equivalent, so the overload matching
12331233 # is ambiguous.
1234- reveal_type(f(list_any)) # revealed: Any
1235- reveal_type(f(* (list_any,))) # revealed: Any
1234+ reveal_type(f(list_any)) # revealed: Unknown
1235+ reveal_type(f(* (list_any,))) # revealed: Unknown
12361236```
12371237
12381238### Single tuple argument
@@ -1277,8 +1277,8 @@ def _(int_str: tuple[int, str], int_any: tuple[int, Any], any_any: tuple[Any, An
12771277
12781278 # All materializations of `tuple[Any, Any]` are assignable to the parameters of all the
12791279 # overloads, but the return types aren't equivalent, so the overload matching is ambiguous
1280- reveal_type(f(any_any)) # revealed: Any
1281- reveal_type(f(* (any_any,))) # revealed: Any
1280+ reveal_type(f(any_any)) # revealed: Unknown
1281+ reveal_type(f(* (any_any,))) # revealed: Unknown
12821282```
12831283
12841284### ` Unknown ` passed into an overloaded function annotated with protocols
@@ -1309,15 +1309,15 @@ def f(a: Foo, b: list[str], c: list[LiteralString], e):
13091309 reveal_type(a.join(b)) # revealed: str
13101310 reveal_type(a.join(c)) # revealed: LiteralString
13111311
1312- # Since both overloads match and they have return types that are not equivalent,
1312+ # since both overloads match and they have return types that are not equivalent,
13131313 # step (5) of the overload evaluation algorithm says we must evaluate the result of the
1314- # call as `Any `.
1314+ # call as `Unknown `.
13151315 #
13161316 # Note: although the spec does not state as such (since intersections in general are not
13171317 # specified currently), `(str | LiteralString) & Unknown` might also be a reasonable type
13181318 # here (the union of all overload returns, intersected with `Unknown`) -- here that would
13191319 # simplify to `str & Unknown`.
1320- reveal_type(a.join(e)) # revealed: Any
1320+ reveal_type(a.join(e)) # revealed: Unknown
13211321```
13221322
13231323### Multiple arguments
@@ -1367,8 +1367,8 @@ def _(list_int: list[int], list_any: list[Any], int_str: tuple[int, str], int_an
13671367 # All materializations of first argument is assignable to the second overload and for the second
13681368 # argument, they're assignable to the third overload, so no overloads are filtered out; the
13691369 # return types of the remaining overloads are not equivalent, so overload matching is ambiguous
1370- reveal_type(f(list_int, any_any)) # revealed: Any
1371- reveal_type(f(* (list_int, any_any))) # revealed: Any
1370+ reveal_type(f(list_int, any_any)) # revealed: Unknown
1371+ reveal_type(f(* (list_int, any_any))) # revealed: Unknown
13721372```
13731373
13741374### ` LiteralString ` and ` str `
@@ -1400,8 +1400,8 @@ def _(literal: LiteralString, string: str, any: Any):
14001400
14011401 # `Any` matches both overloads, but the return types are not equivalent.
14021402 # Pyright and mypy both reveal `str` here, contrary to the spec.
1403- reveal_type(f(any )) # revealed: Any
1404- reveal_type(f(* (any ,))) # revealed: Any
1403+ reveal_type(f(any )) # revealed: Unknown
1404+ reveal_type(f(* (any ,))) # revealed: Unknown
14051405```
14061406
14071407### Generics
@@ -1436,11 +1436,11 @@ def _(list_int: list[int], list_str: list[str], list_any: list[Any], any: Any):
14361436 reveal_type(f(list_str)) # revealed: str
14371437 reveal_type(f(* (list_str,))) # revealed: str
14381438
1439- reveal_type(f(list_any)) # revealed: Any
1440- reveal_type(f(* (list_any,))) # revealed: Any
1439+ reveal_type(f(list_any)) # revealed: Unknown
1440+ reveal_type(f(* (list_any,))) # revealed: Unknown
14411441
1442- reveal_type(f(any )) # revealed: Any
1443- reveal_type(f(* (any ,))) # revealed: Any
1442+ reveal_type(f(any )) # revealed: Unknown
1443+ reveal_type(f(* (any ,))) # revealed: Unknown
14441444```
14451445
14461446### Generics (multiple arguments)
@@ -1513,7 +1513,7 @@ def _(a_int: A[int], a_str: A[str], a_any: A[Any]):
15131513def _ (b_int : B[int ], b_str : B[str ], b_any : B[Any]):
15141514 reveal_type(b_int.method()) # revealed: int
15151515 reveal_type(b_str.method()) # revealed: str
1516- reveal_type(b_any.method()) # revealed: Any
1516+ reveal_type(b_any.method()) # revealed: Unknown
15171517```
15181518
15191519### Ambiguous ` Any ` overloads (multiple arguments)
@@ -1550,8 +1550,7 @@ def _(x: A[None], y: A[Any]) -> None:
15501550 assert_type(op(x, x), A[None ])
15511551 assert_type(op(x, y), A[None ])
15521552 assert_type(op(y, x), A[None ])
1553- assert_type(op(y, y), Any)
1554- reveal_type(op(y, y)) # revealed: Any
1553+ reveal_type(op(y, y)) # revealed: Unknown
15551554```
15561555
15571556### Variadic argument
@@ -1595,11 +1594,11 @@ def _(arg: list[Any]):
15951594 # Matches both overload and the return types are equivalent
15961595 reveal_type(f1(* arg)) # revealed: A
15971596 # Matches both overload but the return types aren't equivalent
1598- reveal_type(f2(* arg)) # revealed: Any
1597+ reveal_type(f2(* arg)) # revealed: Unknown
15991598 # Filters out the final overload and the return types are equivalent
16001599 reveal_type(f3(* arg)) # revealed: A
16011600 # Filters out the final overload but the return types aren't equivalent
1602- reveal_type(f4(* arg)) # revealed: Any
1601+ reveal_type(f4(* arg)) # revealed: Unknown
16031602```
16041603
16051604### Varidic argument with generics
@@ -1658,15 +1657,15 @@ def _(args1: list[int], args2: list[Any]):
16581657reveal_type(f2()) # revealed: tuple[Any, ...]
16591658reveal_type(f2(1 , 2 )) # revealed: tuple[Literal[1], Literal[2]]
16601659# TODO : Should be `tuple[Literal[1], Literal[2]]`
1661- reveal_type(f2(x1 = 1 , x2 = 2 )) # revealed: Any
1660+ reveal_type(f2(x1 = 1 , x2 = 2 )) # revealed: Unknown
16621661# TODO : Should be `tuple[Literal[2], Literal[1]]`
1663- reveal_type(f2(x2 = 1 , x1 = 2 )) # revealed: Any
1662+ reveal_type(f2(x2 = 1 , x1 = 2 )) # revealed: Unknown
16641663reveal_type(f2(1 , 2 , z = 3 )) # revealed: tuple[Any, ...]
16651664
16661665reveal_type(f3(1 , 2 )) # revealed: tuple[Literal[1], Literal[2]]
16671666reveal_type(f3(1 , 2 , 3 )) # revealed: tuple[Any, ...]
16681667# TODO : Should be `tuple[Literal[1], Literal[2]]`
1669- reveal_type(f3(x1 = 1 , x2 = 2 )) # revealed: Any
1668+ reveal_type(f3(x1 = 1 , x2 = 2 )) # revealed: Unknown
16701669reveal_type(f3(z = 1 )) # revealed: dict[str, Any]
16711670
16721671# error: [no-matching-overload]
@@ -1823,8 +1822,8 @@ from typing import Any
18231822from overloaded import A, B, C, f
18241823
18251824def _ (arg : tuple[A | B, Any]):
1826- reveal_type(f(arg)) # revealed: A | Any
1827- reveal_type(f(* (arg,))) # revealed: A | Any
1825+ reveal_type(f(arg)) # revealed: A | Unknown
1826+ reveal_type(f(* (arg,))) # revealed: A | Unknown
18281827```
18291828
18301829#### Both argument lists ambiguous
@@ -1857,8 +1856,8 @@ from typing import Any
18571856from overloaded import A, B, C, f
18581857
18591858def _ (arg : tuple[A | B, Any]):
1860- reveal_type(f(arg)) # revealed: Any
1861- reveal_type(f(* (arg,))) # revealed: Any
1859+ reveal_type(f(arg)) # revealed: Unknown
1860+ reveal_type(f(* (arg,))) # revealed: Unknown
18621861```
18631862
18641863### Unknown argument with TypeVar overload
@@ -1888,10 +1887,10 @@ from nonexistent_module import something_unknown # error: [unresolved-import]
18881887
18891888reveal_type(something_unknown) # revealed: Unknown
18901889
1891- # The result should be `Any `, not `Literal[b""]`.
1892- reveal_type(f(something_unknown)) # revealed: Any
1893- reveal_type(f((something_unknown, something_unknown, something_unknown))) # revealed: Any
1894- reveal_type(f((something_unknown, None , something_unknown))) # revealed: Any
1890+ # The result should be `Unknown `, not `Literal[b""]`.
1891+ reveal_type(f(something_unknown)) # revealed: Unknown
1892+ reveal_type(f((something_unknown, something_unknown, something_unknown))) # revealed: Unknown
1893+ reveal_type(f((something_unknown, None , something_unknown))) # revealed: Unknown
18951894
18961895# Concrete arguments should still resolve correctly.
18971896def _ (s : str ):
0 commit comments