Passed
Push — master ( ce73ec...38d9d4 )
by Max
01:00
created

structured_data._nillable_write.nillable_write()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nop 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
import typing
2
3
_K = typing.TypeVar("_K")
4
_V = typing.TypeVar("_V")
5
6
7
def nillable_write(dct: typing.Dict[_K, _V], key: _K, value: typing.Optional[_V]):
8
    if value is None:
9
        dct.pop(key, typing.cast(_V, None))
10
    else:
11
        dct[key] = value
12