Skip to content

Type inference of or and Optional[x] #1733

Closed
@JukkaL

Description

@JukkaL

When using --strict-optional, the type of a is incorrectly Union[None, str]:

from typing import Optional

def f(x: Optional[str]) -> None:
    a = x or 'default'
    reveal_type(a)  # should be str

#1698 seems related.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions