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
Apologies if this is already reported, it's hard to know what words to look for
I think this is a bug in the "not None inference"
source:
from typing import List, Optional
idx = 0
lst: List[Optional[int]] = []
lst[0] is not None and reveal_type(lst[0])
lst[idx] is not None and reveal_type(lst[idx])
$ mypy foo.py
foo.py:6: note: Revealed type is 'builtins.int'
foo.py:7: note: Revealed type is 'Union[builtins.int, None]'
i would have expected mypy to also tell that the index lookup is identical when it's using a var idx and infer the type to be not-None
Apologies if this is already reported, it's hard to know what words to look for
I think this is a bug in the "not None inference"
source:
i would have expected mypy to also tell that the index lookup is identical when it's using a var
idx
and infer the type to be not-NoneThe text was updated successfully, but these errors were encountered: