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

structured_data._nillable_write   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A nillable_write() 0 5 2
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