mypy icon indicating copy to clipboard operation
mypy copied to clipboard

(🎁) narrow falsey string to `Literal[""]`

Open KotlinIsland opened this issue 1 year ago • 0 comments

from typing import Literal

def f() -> Literal[""]:
    a = ""
    return a and exit()  # error: Incompatible return value type (got "str", expected "Literal['']")  [return-value]

KotlinIsland avatar Feb 07 '24 23:02 KotlinIsland