-
Hello, from typing import Any
class B:
pass
class A:
def __eq__(self, other: Any) -> B: # type: ignore[override]
print("b")
return B()
# It was not failing before because I think it was inferring the __eq__ was overridden
if A() == None: # Condition will always evaluate to False since the types "A" and "None" have no overlap
... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The current behavior is "as designed" even if it's not entirely expected. I see that you have enabled the strict-mode check You're overriding I've fixed many bugs and made other changes since version |
Beta Was this translation helpful? Give feedback.
The current behavior is "as designed" even if it's not entirely expected.
I see that you have enabled the strict-mode check
reportUnnecessaryComparison
. This check needs to make some assumptions about the way comparisons work. These assumptions work in most use cases, but there are edge cases where the heuristic will fail.You're overriding
__eq__
in a very unusual way in this code. In fact, you're overriding the__eq__
method forobject
in an incompatible manner and then ignoring the error using a# type: ignore
comment.I've fixed many bugs and made other changes since version
1.1.224
, so I can't say specifically what caused this to work previously. If you can find the specific version …