Skip to content

Conversation

@sobolevn
Copy link
Member

@sobolevn sobolevn commented Aug 4, 2022

Because __eq__ is treated specially by mypy when strict_equality is turned on.
Without __eq__ on a type, mypy raises this error:

class A:
    def __eq__(self, o: object) -> bool: ...

class B: ...

if A() == 1:  # ok
    ...

if B() == 1: # error: Non-overlapping equality check (left operand type: "B", right operand type: "Literal[1]")
    ...

Refs #8483

@sobolevn sobolevn changed the title Revert __eq__ removal, refs #8483 Revert __eq__ removal Aug 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2022

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit a03e8b4 into python:master Aug 4, 2022
@hauntsaninja
Copy link
Collaborator

Thanks for catching this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants