Typing and Generics

typing.MutableMapping

A mapping supporting insertion, update and deletion. Key and value types are not validated by the runtime annotation. Deprecated typing alias; prefer collections.abc.MutableMapping in modern code (3.9+).

Formal Syntax & Structure

python syntaxpython
typing.MutableMapping[K, V]

Return Value

type expression

Typing construct or runtime result as described; static typing rules are not runtime validation.

Working Example

Example Snippetpython
from typing import MutableMapping
def increment(data:MutableMapping[str,int],key:str)->None: data[key]=data.get(key,0)+1data={"x":2}increment(data,"x")print(data)
Python Reference