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:

  1. from typing import Dict
  2.  
  3. # Error: Dict entry 0 has incompatible type "str": "str"; expected "str": "int" [dict-item]
  4. d: Dict[str, int] = {'key': 'value'}