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
Are you reporting a bug, or opening a feature request?
Feature Request
Please insert below the code you are checking with mypy,
import typing as t
class NotPresent:
def __bool__(self) -> t.Literal[False]:
return False
x: t.Union[NotPresent, t.Sequence[int]] = [1]
reveal_type(x)
if x:
print(x[0])
What is the actual behavior/output? test.py:12:11: error: Value of type "Union[NotPresent, Sequence[int]]" is not indexable
What is the behavior/output you expect?
The if x branch should recognise that x cannot be of type NotPresent (as it would do if it was None rather than NotPresent)
What are the versions of mypy and Python you are using?
0.770 & master
What are the mypy flags you are using? (For example --strict-optional)
None
Feature Request
What is the actual behavior/output?
test.py:12:11: error: Value of type "Union[NotPresent, Sequence[int]]" is not indexableWhat is the behavior/output you expect?
The
if xbranch should recognise that x cannot be of typeNotPresent(as it would do if it wasNonerather thanNotPresent)What are the versions of mypy and Python you are using?
0.770 & master
What are the mypy flags you are using? (For example --strict-optional)
None