Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Non-overlapping identity check false-positive starting in 0.780 #9011

@nipunn1313

Description

@nipunn1313

https://mypy-play.net/?mypy=latest&python=3.8&flags=strict&gist=9b082c260ecb9586b358a06c8583edc2

class A:
    y: bool
    def update(self) -> None:
        pass
    
a = A()
assert a.y is True
a.update()
assert a.y is False

gives

main.py:9: error: Non-overlapping identity check (left operand type: "Literal[True]", right operand type: "Literal[False]")
Found 1 error in 1 file (checked 1 source file)

This may be reasonable opinionated behavior, but wanted to flag it as a behavior change between 0.770 and 0.780
I would personally consider this to be a false positive. It's not obvious how to change the source code to make mypy happy here.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions