Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nipunn1313 opened this issue Jun 17, 2020 · 1 comment · Fixed by #9021
Closed

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

nipunn1313 opened this issue Jun 17, 2020 · 1 comment · Fixed by #9021
Assignees
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-0-high topic-literal-types

Comments

@nipunn1313
Copy link
Contributor

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.

@JukkaL JukkaL added bug mypy got something wrong false-positive mypy gave an error on correct code priority-0-high topic-literal-types labels Jun 18, 2020
@JukkaL JukkaL self-assigned this Jun 18, 2020
@JukkaL
Copy link
Collaborator

JukkaL commented Jun 18, 2020

Yeah, this is a bug and a regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-0-high topic-literal-types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants