diff --git a/msgspec/__init__.pyi b/msgspec/__init__.pyi index 6e4937a0..219fc122 100644 --- a/msgspec/__init__.pyi +++ b/msgspec/__init__.pyi @@ -68,7 +68,9 @@ class Struct: weakref: bool = False, dict: bool = False, ) -> None: ... - def __rich_repr__(self) -> Iterable[Tuple[str, Any]]: ... + def __rich_repr__( + self, + ) -> Iterable[Union[Any, Tuple[Any], Tuple[str, Any], Tuple[str, Any, Any]]]: ... def defstruct( name: str, diff --git a/tests/basic_typing_examples.py b/tests/basic_typing_examples.py index 21cd3fa4..1e686430 100644 --- a/tests/basic_typing_examples.py +++ b/tests/basic_typing_examples.py @@ -311,7 +311,10 @@ class Point(msgspec.Struct): a.x = a.x + b.y repr(a) - for name, val in a.__rich_repr__(): + for item in a.__rich_repr__(): + assert isinstance(item, tuple) + assert len(item) == 2 + name, val = item print(f"{name} = {val}")