Closed
Description
Potential bug. One of my colleagues noticed that a collection of type Collection[Optional[float]]
will act as if it is Collection[Optional[float]]
even after any possible None
is removed.
Minimal Example:
def mypy_subtract(nulled: bool) -> float:
if nulled:
returnable = [None, None]
else:
returnable = [1.0, 2.0]
if None in returnable:
raise Exception
return returnable[0] - returnable[1]
What is the actual behavior/output?
itemscoringmigration/mypy_example.py:5: error: List item 0 has incompatible type "float"; expected "None"
itemscoringmigration/mypy_example.py:5: error: List item 1 has incompatible type "float"; expected "None"
itemscoringmigration/mypy_example.py:10: error: Unsupported left operand type for - ("None")
What is the behavior/output you expect?
No errors.
What are the versions of mypy and Python you are using?
mypy 0.761
Python 3.6.8
Do you see the same issue after installing mypy from Git master?
Yes.
No flags used.
Thanks for all the hard work. I love this package.
Metadata
Metadata
Assignees
Labels
No labels