This is a duplicate of #20600, although I cannot reopen it. Here is an example to reproduce. I believe it was introduced in v1.20.0.
from dataclasses import dataclass
from typing import TypeGuard, Self
@dataclass
class ErrorCase:
x: int
def __eq__(self, other: object) -> TypeGuard[Self]:
return (
type(other)
is type(self)
) and (
self.x # error: "object" has no attribute "x"
== other.x
)
The error on line 14 is a false-positive.
This is a duplicate of #20600, although I cannot reopen it. Here is an example to reproduce. I believe it was introduced in v1.20.0.
The error on line 14 is a false-positive.