msgspec icon indicating copy to clipboard operation
msgspec copied to clipboard

UnsetType union types lowering is incomplete

Open CharString opened this issue 3 months ago • 0 comments

Description

from typing import assert_type
from msgspec import UnsetType


def f(s: str | UnsetType):
    if s:
        assert_type(s, str)  # this fails

UNSET is the only UnsetType value and bool(UNSET) is False. Therefore the if statement should narrow the type of s to str.

CharString avatar Nov 05 '25 21:11 CharString