-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Issue with Narrowing #21173
Copy link
Copy link
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong