Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/pandas/compat/chainmap.py: 33%
17 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1from __future__ import annotations
3from typing import (
4 ChainMap,
5 TypeVar,
6)
8_KT = TypeVar("_KT")
9_VT = TypeVar("_VT")
12class DeepChainMap(ChainMap[_KT, _VT]):
13 """
14 Variant of ChainMap that allows direct updates to inner scopes.
16 Only works when all passed mapping are mutable.
17 """
19 def __setitem__(self, key: _KT, value: _VT) -> None:
20 for mapping in self.maps:
21 if key in mapping:
22 mapping[key] = value
23 return
24 self.maps[0][key] = value
26 def __delitem__(self, key: _KT) -> None:
27 """
28 Raises
29 ------
30 KeyError
31 If `key` doesn't exist.
32 """
33 for mapping in self.maps:
34 if key in mapping:
35 del mapping[key]
36 return
37 raise KeyError(key)