-
Notifications
You must be signed in to change notification settings - Fork 143
Closed as duplicate of#559
Labels
control flownarrowingrelated to flow-sensitive type narrowingrelated to flow-sensitive type narrowing
Description
Summary
Mypy and pyright apparently do not have this problem. In my example below, obj from inner_func is guaranteed to be a type string. This can also be seen in the first reveal_type. However, it seems that ty is taking the type of obj to be the input argument one (int | str) instead of the narrowed down (str)
from collections.abc import Mapping
from typing import Any
from typing_extensions import reveal_type
def func(obj: int | str) -> None:
obj = str(obj) if isinstance(obj, int) else obj
reveal_type(obj) # str
def inner_func():
reveal_type(obj) # int | strVersion
0.0.1-alpha.19
Metadata
Metadata
Assignees
Labels
control flownarrowingrelated to flow-sensitive type narrowingrelated to flow-sensitive type narrowing