Skip to content

Type __rich_repr__ as rich.repr.Result #552

Description

@dhirschfeld

Description

I'm trying to type an api and have used the below definition:

class HasRichRepr(Protocol):
    def __rich_repr__(self) -> rich.repr.Result:

...which appears to conflict with the type definitionon the struct:

Return type "Iterable[Any | tuple[Any] | tuple[str, Any] | tuple[str, Any, Any]]" of "__rich_repr__" incompatible with return type "Iterable[tuple[str, Any]]" in supertype "Struct"  [override]

https://github.com/jcrist/msgspec/blob/256d84a2f233ee741a2c2e4d67633b13ffcd37a4/msgspec/__init__.pyi#L71

It would probably be good to align the type with the definition upstream?

def __rich_repr__(self) -> Iterable[Any | tuple[Any] | tuple[str, Any] | tuple[str, Any, Any]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions