Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in mypy 0.930: object.__reduce__ #6661

Closed
dvarrazzo opened this issue Dec 22, 2021 · 5 comments · Fixed by #6662
Closed

Regression in mypy 0.930: object.__reduce__ #6661

dvarrazzo opened this issue Dec 22, 2021 · 5 comments · Fixed by #6662
Labels
stubs: false positive Type checkers report false errors

Comments

@dvarrazzo
Copy link

dvarrazzo commented Dec 22, 2021

In mypy 0.930 the signature for object.__reduce__ has been changed to

    def __reduce__(self) -> str | Tuple[object, ...]: ...

This is wrong, reading the documentation. The following valid code now is reported as error:

from typing import Any, Tuple, Union


class Diagnostic:
    def __reduce__(self) -> Union[str, Tuple[Any, ...]]:
        res = super().__reduce__()
        if isinstance(res, tuple) and len(res) >= 3:
            res[2]["_info"] = 42

        return res
@dvarrazzo
Copy link
Author

Note: broken in 88f86a0

@srittau
Copy link
Collaborator

srittau commented Dec 22, 2021

Yeah, the return type of __reduce__ is documented, so we should revert this change. Cc @AlexWaygood

@AlexWaygood
Copy link
Member

Yes, my bad. Needs to be reverted, agreed.

dvarrazzo added a commit to psycopg/psycopg that referenced this issue Dec 22, 2021
The release is affected by the issues:

- python/mypy#11820
- python/typeshed#6661

already acknowledged as bugs.
AlexWaygood added a commit to AlexWaygood/typeshed that referenced this issue Dec 22, 2021
Reverts regressions introduced by python#6292. Fixes python#6661.
JelleZijlstra pushed a commit that referenced this issue Dec 22, 2021
Reverts regressions introduced by #6292. Fixes #6661.
dvarrazzo added a commit to psycopg/psycopg that referenced this issue Dec 23, 2021
The release is affected by the issues:

- python/mypy#11820
- python/typeshed#6661

already acknowledged as bugs.
@hauntsaninja
Copy link
Collaborator

@dvarrazzo this should be fixed in mypy 0.931, even if python/mypy#11820 isn't

@dvarrazzo
Copy link
Author

Yes, this is fixed alright :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false positive Type checkers report false errors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants