Skip to content

Incorrect union narrowing in expression with assignments #8128

@elprans

Description

@elprans

bug.py:

from __future__ import annotations
from typing import *


def foo() -> Optional[str]:
    return None


if ((f := foo()) is None or f.lower()):
    pass
$ mypy bug.py
bug.py:9: error: Item "None" of "Optional[str]" has no attribute "lower"
Found 1 error in 1 file (checked 1 source file)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions