Skip to content

Commit cdbd737

Browse files
committed
incorrect tests
1 parent cce6a71 commit cdbd737

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

test-data/unit/check-enum.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ reveal_type(x) # N: Revealed type is "__main__.Foo"
13151315

13161316
# ..and we get the same result if we have two disjoint groups within the same comp expr
13171317
if x is Foo.A < x is Foo.B:
1318-
reveal_type(x) # E: Statement is unreachable
1318+
reveal_type(x) # N: Revealed type is "__main__.Foo"
13191319
else:
13201320
reveal_type(x) # N: Revealed type is "__main__.Foo"
13211321
reveal_type(x) # N: Revealed type is "__main__.Foo"
@@ -1333,9 +1333,9 @@ class Foo(Enum):
13331333

13341334
x: Foo
13351335
if x is Foo.A is Foo.B:
1336-
reveal_type(x) # E: Statement is unreachable
1336+
reveal_type(x) # N: Revealed type is "Literal[__main__.Foo.A] | Literal[__main__.Foo.B]"
13371337
else:
1338-
reveal_type(x) # N: Revealed type is "__main__.Foo"
1338+
reveal_type(x) # N: Revealed type is "Literal[__main__.Foo.C]"
13391339
reveal_type(x) # N: Revealed type is "__main__.Foo"
13401340

13411341
literal_a: Literal[Foo.A]

test-data/unit/check-isinstance.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2729,7 +2729,7 @@ from typing import Union
27292729

27302730
y: str
27312731
if type(y) is int: # E: Subclass of "str" and "int" cannot exist: would have incompatible method signatures
2732-
y # E: Statement is unreachable
2732+
y # E: Statement is unreachable
27332733
else:
27342734
reveal_type(y) # N: Revealed type is "builtins.str"
27352735
[builtins fixtures/isinstance.pyi]

test-data/unit/check-narrowing.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,7 @@ def f(x: str | int) -> None:
22962296
if x in ["x"]:
22972297
# TODO: we should fix this reveal https://github.com/python/mypy/issues/3229
22982298
reveal_type(x) # N: Revealed type is "builtins.str | builtins.int"
2299-
y = x
2299+
y = x # E: Incompatible types in assignment (expression has type "str | int", variable has type "str")
23002300
z = x
23012301
z = y
23022302
[builtins fixtures/primitives.pyi]

test-data/unit/check-optional.test

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,11 @@ def main(x: Union[str, int, None]):
474474
from typing import Union
475475
x = '' # type: Union[str, int, None]
476476
if x == object():
477-
reveal_type(x) # N: Revealed type is "builtins.str | builtins.int"
477+
reveal_type(x) # N: Revealed type is "builtins.str | builtins.int | None"
478478
else:
479479
reveal_type(x) # N: Revealed type is "builtins.str | builtins.int | None"
480480
if x is object():
481-
reveal_type(x) # N: Revealed type is "builtins.str | builtins.int"
481+
reveal_type(x) # N: Revealed type is "builtins.str | builtins.int | None"
482482
else:
483483
reveal_type(x) # N: Revealed type is "builtins.str | builtins.int | None"
484484
[builtins fixtures/ops.pyi]
@@ -489,7 +489,7 @@ from typing import Optional
489489

490490
def main(x: Optional[str]):
491491
if x == 0:
492-
reveal_type(x) # E: Statement is unreachable
492+
reveal_type(x) # N: Revealed type is "builtins.str | None"
493493
else:
494494
reveal_type(x) # N: Revealed type is "builtins.str | None"
495495
if x is 0:
@@ -514,21 +514,21 @@ else:
514514

515515
[case testInferEqualsNotOptionalWithMultipleArgs]
516516
from typing import Optional
517-
x: Optional[int]
518-
y: Optional[int]
519-
if x == y == 1:
520-
reveal_type(x) # N: Revealed type is "builtins.int"
521-
reveal_type(y) # N: Revealed type is "builtins.int"
522-
else:
523-
reveal_type(x) # N: Revealed type is "builtins.int | None"
524-
reveal_type(y) # N: Revealed type is "builtins.int | None"
517+
518+
def main(x: Optional[int], y: Optional[int]):
519+
if x == y == 1:
520+
reveal_type(x) # N: Revealed type is "builtins.int | None"
521+
reveal_type(y) # N: Revealed type is "builtins.int | None"
522+
else:
523+
reveal_type(x) # N: Revealed type is "builtins.int | None"
524+
reveal_type(y) # N: Revealed type is "builtins.int | None"
525525

526526
class A: pass
527527
a: Optional[A]
528528
b: Optional[A]
529529
if a == b == object():
530-
reveal_type(a) # N: Revealed type is "__main__.A"
531-
reveal_type(b) # N: Revealed type is "__main__.A"
530+
reveal_type(a) # N: Revealed type is "__main__.A | None"
531+
reveal_type(b) # N: Revealed type is "__main__.A | None"
532532
else:
533533
reveal_type(a) # N: Revealed type is "__main__.A | None"
534534
reveal_type(b) # N: Revealed type is "__main__.A | None"

test-data/unit/check-python310.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,9 +2938,9 @@ T_Choice = TypeVar("T_Choice", bound=b.One | b.Two)
29382938
def switch(choice: type[T_Choice]) -> None:
29392939
match choice:
29402940
case b.One:
2941-
reveal_type(choice) # N: Revealed type is "type[T_Choice`-1]"
2941+
reveal_type(choice) # N: Revealed type is "def () -> b.One"
29422942
case b.Two:
2943-
reveal_type(choice) # N: Revealed type is "type[T_Choice`-1]"
2943+
reveal_type(choice) # N: Revealed type is "def () -> b.Two"
29442944
case _:
29452945
reveal_type(choice) # N: Revealed type is "type[T_Choice`-1]"
29462946

0 commit comments

Comments
 (0)