Skip to content

object.__reduce__ might return a string #3452

Closed
@MSeifert04

Description

@MSeifert04

I have a type which returns a string in __reduce__ which leads to a mypy failure:

Return type "str" of "__reduce__" incompatible with return type "Tuple[Any, ...]" in supertype "object"

According to the __reduce__ documentation this method can return a string or a Tuple.

Would it make sense to change the typing to __reduce__(self) -> Union[str, Tuple[Any, ...]]: ...?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions