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
Here's an example where I'm allowed to index a NumPy array after narrowing its otherwise optional type when I do so directly, but not when I use it as part of a key for max .
I wouldn't have expected a[x] to be problematic, since we know a is not None at this point. MyPy itself seems to be aware since the preceding line, containing an a[0], does not cause any errors.
Actual Behavior
main.py:11: error: Value of type "Any | None" is not indexable [index]
Your Environment
Mypy version used: 1.6.1
Mypy command-line flags: None.
Mypy configuration options from mypy.ini (and other config files): None
Python version used: 3.11.5
The text was updated successfully, but these errors were encountered:
Bug Report
Here's an example where I'm allowed to index a NumPy array after narrowing its otherwise optional type when I do so directly, but not when I use it as part of a
key
formax
.To Reproduce
https://gist.github.com/mypy-play/beca56edcf56c561ebfb37147d31c2ed
That is,
Expected Behavior
I wouldn't have expected
a[x]
to be problematic, since we knowa is not None
at this point. MyPy itself seems to be aware since the preceding line, containing ana[0]
, does not cause any errors.Actual Behavior
Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: