-
-
Notifications
You must be signed in to change notification settings - Fork 12k
Closed
Labels
Description
While I haven't found documentation for it, a structured dtype can be indexed with a single field name to obtain the dtype of that field or with a list of field names to get a dtype of the same size with that subset of fields. The type annotations for these are missing, causing mypy to complain after updating to numpy 1.20.
Reproducing code example:
import numpy as np
d = np.dtype('i8,i4')
print(d['f0'])
print(d[['f0']])Error message:
The code works, and outputs
int64
{'names':['f0'], 'formats':['<i8'], 'offsets':[0], 'itemsize':12}
However, mypy 0.790 reports
dtype.py:4: error: Value of type "dtype[Any]" is not indexable
dtype.py:5: error: Value of type "dtype[Any]" is not indexable
NumPy/Python version information:
1.20.1 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0]