Skip to content

Strict equality false positive with lists having different item types #14511

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

Closed
JukkaL opened this issue Jan 23, 2023 · 0 comments · Fixed by #14513
Closed

Strict equality false positive with lists having different item types #14511

JukkaL opened this issue Jan 23, 2023 · 0 comments · Fixed by #14513
Assignees
Labels
bug mypy got something wrong

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jan 23, 2023

This generate a false positive when using --strict-equality:

class C: pass
class D:
    def __eq__(self, other): return True

a = [C()]
b = [D()]
C() == D()  # No error
print(a == b)  # error: Non-overlapping equality check (left operand type: "List[C]", right operand type: "List[D]")
@JukkaL JukkaL added the bug mypy got something wrong label Jan 23, 2023
@JukkaL JukkaL self-assigned this Jan 23, 2023
JukkaL added a commit that referenced this issue Jan 23, 2023
Don't complain about comparing lists, variable-legnth tuples or sets if
one of the operands has an item type with a custom __eq__ method.

Fix #14511.
ilinum pushed a commit that referenced this issue Jan 23, 2023
)

Don't complain about comparing lists, variable-length tuples or sets if
one of the operands has an item type with a custom `__eq__` method.

Fix #14511.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant