Passed
Pull Request — master (#17)
by Ramon
50s
created

default_list_deserializer()   A

Complexity

Conditions 3

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 3
nop 3
1
from jsons._main_impl import load
2
3
4
def default_list_deserializer(obj: list, cls: type = None, **kwargs) -> list:
5
    """
6
    Deserialize a list by deserializing all items of that list.
7
    :param obj: the list that needs deserializing.
8
    :param cls: the type optionally with a generic (e.g. List[str]).
9
    :param kwargs: any keyword arguments.
10
    :return: a deserialized list instance.
11
    """
12
    cls_ = None
13
    if cls and hasattr(cls, '__args__'):
14
        cls_ = cls.__args__[0]
15
    return [load(x, cls_, **kwargs) for x in obj]
16