Skip to content

Issue with Narrowing #21173

Description

@George-Ogden

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.

fromdataclassesimportdataclassfromtypingimportTypeGuard, Self@dataclassclassErrorCase:
x: intdef__eq__(self, other: object) ->TypeGuard[Self]:
return (
type(other)
istype(self)
) and (
self.x# error: "object" has no attribute "x"==other.x
)

The error on line 14 is a false-positive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions