Skip to content

Commit 4849aaf

Browse files
committed
fix
1 parent e42a427 commit 4849aaf

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

mypy/checker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8311,6 +8311,7 @@ def conditional_types(
83118311
proposed_type_ranges,
83128312
default=union_item,
83138313
consider_runtime_isinstance=consider_runtime_isinstance,
8314+
ignore_promotions=ignore_promotions,
83148315
)
83158316
for union_item in get_proper_types(proper_type.items)
83168317
]

test-data/unit/check-narrowing.test

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3272,7 +3272,7 @@ TargetType = TypeVar("TargetType", int, float, str)
32723272
def convert_type(target_type: Type[TargetType]) -> TargetType:
32733273
if target_type == str:
32743274
return str()
3275-
if target_type == int:s
3275+
if target_type == int:
32763276
return int()
32773277
if target_type == float:
32783278
return float()
@@ -3293,10 +3293,14 @@ def f2(number: float, five: Literal[5]):
32933293
if number == five:
32943294
reveal_type(number) # N: Revealed type is "Literal[5]"
32953295

3296+
def f3(number: float | None, i: int):
3297+
if number == i:
3298+
reveal_type(number) # N: Revealed type is "builtins.int"
3299+
32963300
class Custom:
32973301
def __eq__(self, other: object) -> bool: return True
32983302

3299-
def f3(number: float, x: Custom | int):
3303+
def f4(number: float, x: Custom | int):
33003304
if number == x:
33013305
reveal_type(number) # N: Revealed type is "builtins.float"
33023306
reveal_type(x) # N: Revealed type is "__main__.Custom | builtins.int"

0 commit comments

Comments
 (0)