Check dict items [dict-item]
When constructing a dictionary using {key: value, …}
or dict(key=value, …)
,mypy checks that each key and value is compatible with the dictionary type that isinferred from the surrounding context.
Example:
- from typing import Dict
- # Error: Dict entry 0 has incompatible type "str": "str"; expected "str": "int" [dict-item]
- d: Dict[str, int] = {'key': 'value'}