Failure to detect non-None Optional type in conditional expression #6755
Labels
bug
mypy got something wrong
false-positive
mypy gave an error on correct code
priority-1-normal
topic-strict-optional
Are you reporting a bug, or opening a feature request?
Bug
Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to simplify your case to a minimal repro.
This error is only thrown for conditional expressions of the form
if container[index] else None
. Changing it to any of the following works as expected:What is the behavior/output you expect?
No errors reported.
What are the versions of mypy and Python you are using?
mypy 0.701, reproducible on at least Python 2.7 and 3.7.
Do you see the same issue after installing mypy from Git master?
Yes
The text was updated successfully, but these errors were encountered: