Check indexing operations [index]
Mypy checks that the indexed value in indexing operation such asx[y]
supports indexing, and that the index expression has a validtype.
Example:
- a = {'x': 1, 'y': 2}
- a['x'] # OK
- # Error: Invalid index type "int" for "Dict[str, int]"; expected type "str" [index]
- print(a[1])
- # Error: Invalid index type "bytes" for "Dict[str, int]"; expected type "str" [index]
- a[b'x'] = 4