Skip to content

Partial type that is "initialised" via assignment is only temporarily narrowed by isinstance #18238

Description

@tyralla

In the following example, the last revealed type could/should be Union[builtins.int, None]:

deff() ->bool: returnTrueu: int|tuple[int]
x=Noneiff():
x=uifisinstance(x, tuple):
x=x[0]
reveal_type(x) # note: "builtins.int"reveal_type(x) # note: Revealed type is "Union[builtins.int, Tuple[builtins.int], None]"

See this comment for background information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-type-narrowingConditional type narrowing / binder

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions