DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
http://docs.basedpyright.com/
Other
613 stars 13 forks source link

narrowing does not work when the variable being narrowed is on the right hand side of the `==` operator #392

Open DetachHead opened 1 month ago

DetachHead commented 1 month ago

original issue: https://github.com/microsoft/pyright/issues/8064

def f(a: int | None):
    if 1 == a:
        reveal_type(a)  # int | None
    if a == 1:
        reveal_type(a)  # Literal[1]

playground