Skip to content

Mappings

merge(*mappings: Mapping[Any, Any], **keywords: Any) -> Dict[Any, Any]

Merges multiple mappings and keywords into one dictionary.

Parameters:

Name Type Description Default
*mappings Mapping[Any, Any]

Mappings to merge.

()
**keywords Any

Keywords to add to the merged dictionary.

{}

Returns:

Type Description
Dict[Any, Any]

The merged dictionary.

Source code in iters/mappings.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def merge(*mappings: Mapping[Any, Any], **keywords: Any) -> Dict[Any, Any]:
    """Merges multiple `mappings` and `keywords` into one dictionary.

    Arguments:
        *mappings: Mappings to merge.
        **keywords: Keywords to add to the merged dictionary.

    Returns:
        The merged dictionary.
    """
    merged: Dict[Any, Any] = {}

    for mapping in mappings:
        merged.update(mapping)

    merged.update(keywords)

    return merged