Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

typing.Dict — legacy dictionary annotation

typing.Dict describes dictionary key and value types. Since Python 3.9 it is a deprecated alias of dict; use dict[K, V] in new code. The annotation does not validate data at runtime.

Version: Python 3.14; repository image, production runtime not attested

Syntax

from typing import Dict
name: Dict[KeyType, ValueType] = {}

typing.Dict[K, V] describes a dictionary with keys of type K and values of type V. After from typing import Dict, Dict[str, int] means str keys and int values.

The alias has been deprecated since Python 3.9 but remains available in Python 3.14. Use dict[str, int] in new code. For parameters needing only read access, prefer collections.abc.Mapping[str, int].

The annotation supports static analysis tools; it does not enforce types at runtime. In the example, scores remains an ordinary dict: updating the value produces 5, and reading the type name produces dict.

Examples

from typing import Dict

scores: Dict[str, int] = {"Ada": 3}
scores["Ada"] += 2
print(scores["Ada"])
print(type(scores).__name__)

Result

5
dict

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources