@@ -1400,8 +1400,8 @@ a: Any
1400
1400
b: List[Any]
1401
1401
c: List[str]
1402
1402
d: List[int]
1403
- reveal_type(f(a)) # E: Revealed type is 'builtins.list[ Any] '
1404
- reveal_type(f(b)) # E: Revealed type is 'builtins.list[ Any] '
1403
+ reveal_type(f(a)) # E: Revealed type is 'Any'
1404
+ reveal_type(f(b)) # E: Revealed type is 'Any'
1405
1405
reveal_type(f(c)) # E: Revealed type is 'builtins.list[Any]'
1406
1406
reveal_type(f(d)) # E: Revealed type is 'builtins.list[builtins.int]'
1407
1407
@@ -1443,6 +1443,54 @@ reveal_type(f(**a)) # E: Revealed type is 'Any'
1443
1443
1444
1444
[builtins fixtures/dict.pyi]
1445
1445
1446
+ [case testOverloadWithOverlappingItemsAndAnyArgument12]
1447
+ from typing import overload, Any
1448
+
1449
+ @overload
1450
+ def f(x: int) -> Any: ...
1451
+ @overload
1452
+ def f(x: str) -> str: ...
1453
+ def f(x): pass
1454
+
1455
+ a: Any
1456
+ reveal_type(f(a)) # E: Revealed type is 'Any'
1457
+
1458
+ [case testOverloadWithOverlappingItemsAndAnyArgument13]
1459
+ from typing import Any, overload, TypeVar, Generic
1460
+
1461
+ class slice: pass
1462
+
1463
+ T = TypeVar('T')
1464
+ class A(Generic[T]):
1465
+ @overload
1466
+ def f(self, x: int) -> T: ...
1467
+ @overload
1468
+ def f(self, x: slice) -> A[T]: ...
1469
+ def f(self, x): ...
1470
+
1471
+ i: Any
1472
+ a: A[Any]
1473
+ reveal_type(a.f(i)) # E: Revealed type is 'Any'
1474
+
1475
+ [case testOverloadWithOverlappingItemsAndAnyArgument14]
1476
+ from typing import overload, Any, Union
1477
+
1478
+ @overload
1479
+ def f(x: int) -> str: ...
1480
+ @overload
1481
+ def f(x: str) -> str: ...
1482
+ def f(x): pass
1483
+
1484
+ @overload
1485
+ def g(x: int) -> Union[str, int]: ...
1486
+ @overload
1487
+ def g(x: str) -> Union[int, str]: ...
1488
+ def g(x): pass
1489
+
1490
+ a: Any
1491
+ reveal_type(f(a)) # E: Revealed type is 'builtins.str'
1492
+ reveal_type(g(a)) # E: Revealed type is 'Union[builtins.str, builtins.int]'
1493
+
1446
1494
[case testOverloadOnOverloadWithType]
1447
1495
from typing import Any, Type, TypeVar, overload
1448
1496
from mod import MyInt
0 commit comments