Skip to content

Commit 2d67fc3

Browse files
committed
Fix some test cases
1 parent e77113a commit 2d67fc3

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

test-data/unit/check-isinstance.test

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,9 +2077,7 @@ class A: pass
20772077

20782078
def foo1(x: Union[A, str, None]) -> None:
20792079
if x is None:
2080-
# Since None is a subtype of all types in no-strict-optional,
2081-
# we can't really narrow the type here
2082-
reveal_type(x) # E: Revealed type is 'Union[__main__.A, builtins.str, None]'
2080+
reveal_type(x) # E: Revealed type is 'None'
20832081
elif isinstance(x, A):
20842082
# Note that Union[None, A] == A in no-strict-optional
20852083
reveal_type(x) # E: Revealed type is '__main__.A'
@@ -2088,12 +2086,12 @@ def foo1(x: Union[A, str, None]) -> None:
20882086

20892087
def foo2(x: Optional[str]) -> None:
20902088
if x is None:
2091-
reveal_type(x) # E: Revealed type is 'Union[builtins.str, None]'
2089+
reveal_type(x) # E: Revealed type is 'None'
20922090
elif isinstance(x, A):
20932091
# Mypy should, however, be able to skip impossible cases
20942092
reveal_type(x)
20952093
else:
2096-
reveal_type(x) # E: Revealed type is 'Union[builtins.str, None]'
2094+
reveal_type(x) # E: Revealed type is 'builtins.str'
20972095
[builtins fixtures/isinstance.pyi]
20982096

20992097
[case testNoneCheckDoesNotNarrowWhenUsingTypeVars]
@@ -2153,7 +2151,7 @@ def bar(x: Union[List[str], List[int], None]) -> None:
21532151
from typing import Union, Optional, List
21542152

21552153
# This test is the same as the one above, except for strict-optional.
2156-
# It isn't testing anything explicitly and mostly exists for the sake
2154+
# It isn't testing anything explicitly and mostly exists for the sake
21572155
# of completeness.
21582156

21592157
def foo(x: Optional[List[str]]) -> None:
@@ -2166,4 +2164,3 @@ def bar(x: Union[List[str], List[int], None]) -> None:
21662164
assert isinstance(x, list)
21672165
reveal_type(x) # E: Revealed type is 'Union[builtins.list[builtins.str], builtins.list[builtins.int]]'
21682166
[builtins fixtures/isinstancelist.pyi]
2169-

test-data/unit/check-tuples.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ possibles: Tuple[int, Tuple[A]]
10991099
x: Optional[Tuple[B]]
11001100

11011101
if x in possibles:
1102-
reveal_type(x) # E: Revealed type is 'Union[Tuple[__main__.B], None]'
1102+
reveal_type(x) # E: Revealed type is 'Tuple[__main__.B]'
11031103
else:
11041104
reveal_type(x) # E: Revealed type is 'Union[Tuple[__main__.B], None]'
11051105

test-data/unit/check-unreachable-code.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ class Child(Parent):
599599
def foo(self) -> int:
600600
reveal_type(self) # E: Revealed type is '__main__.Child'
601601
if self is None:
602-
reveal_type(self) # E: Revealed type is '__main__.Child'
602+
reveal_type(self) # E: Revealed type is 'None'
603603
return None
604604
reveal_type(self) # E: Revealed type is '__main__.Child'
605605
return 3

0 commit comments

Comments
 (0)