You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug?] Inability to recognize None type has been removed from collection #8279
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.
Closing as duplicate of #2980. This is a relatively low-priority feature since this comes up pretty rarely and the implementation would be non-trivial (and there are some potential type safety issues).
Activity
JukkaL commentedon Jan 15, 2020
Closing as duplicate of #2980. This is a relatively low-priority feature since this comes up pretty rarely and the implementation would be non-trivial (and there are some potential type safety issues).