Skip to content

Commit

Permalink
Fix __rich_repr__ type annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed Oct 3, 2023
1 parent d3abf75 commit 792d8ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion msgspec/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion tests/basic_typing_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")


Expand Down

0 comments on commit 792d8ea

Please sign in to comment.