Check list items [list-item]
When constructing a list using [item, …]
, mypy checks that each itemis compatible with the list type that is inferred from the surroundingcontext.
Example:
- from typing import List
- # Error: List item 0 has incompatible type "int"; expected "str" [list-item]
- a: List[str] = [0]