Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/msgspec/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ T = TypeVar("T")

class UnsetType(enum.Enum):
UNSET = "UNSET"
def __bool__(self) -> Literal[False]: ...

UNSET = UnsetType.UNSET

Expand Down
5 changes: 5 additions & 0 deletions tests/typing/basic_typing_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def check_unset_type_lowering(x: int | msgspec.UnsetType) -> None:
reveal_type(x) # assert "unset" not in typ.lower()


def check_unset_type_truthiness_lowering(x: str | msgspec.UnsetType) -> None:
if x:
reveal_type(x) # assert "unset" not in typ.lower()


def check_nodefault() -> None:
reveal_type(msgspec.NODEFAULT) # assert "Any" not in typ
str(msgspec.NODEFAULT)
Expand Down
Loading