Inference of Any against optional type infers Never #8829
Labels
bug
mypy got something wrong
priority-0-high
topic-type-narrowing
Conditional type narrowing / binder
topic-type-variables
See the following example:
I would expect that
foo1
andfoo2
are equivalent. However, runningmypy
on this file, I get:test.py:12: error: Value of type <nothing> is not indexable
For some reason,
assert_not_none
doesn't mapOptional[Any]
toAny
, as it is supposed to (and which would accept the indexing), but instead maps it to<nothing>
which throws an error. The second version with asserting that it is not None seems to work fine, though.The text was updated successfully, but these errors were encountered: