Open
Description
Here's a very simple example:
from typing import *
a = ['x', None] # type: List[Optional[str]]
for i in range(len(a)):
if a[i]:
print(i, '<' + a[i] + '>')
We get an error on the last line:
__tmp__.py:5: error: Unsupported operand types for + ("str" and "Optional[str]")
Of course I can refactor this by using
for i in range(len(a)):
ai = a[i]
if ai:
print(i, '<' + ai + '>')
but that's just busy-work and doesn't necessarily make the code more readable.
(I found this in some mypy test code where the actual expression was p[i].arg
so this probably needs to become fairly powerful.)