jsons.deserializers.default_nonetype   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A default_nonetype_deserializer() 0 14 2
1
from typing import Optional
2
3
from jsons.exceptions import DeserializationError
4
5
6
def default_nonetype_deserializer(obj: object,
7
                                  cls: Optional[type] = None,
8
                                  **kwargs) -> object:
9
    """
10
    Deserialize a ``NoneType``.
11
    :param obj: the value that is to be deserialized.
12
    :param cls: not used.
13
    :param kwargs: not used.
14
    :return: ``obj``.
15
    """
16
    if obj is not None:
17
        raise DeserializationError('Cannot deserialize {} as NoneType'
18
                                   .format(obj), source=obj, target=cls)
19
    return obj
20