models.user_past_races.UserPastRaces.from_dict()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 8
Code Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 8
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 2
nop 1
1
from dataclasses import dataclass
2
from typing import Any, List
3
from models import from_int, from_list
4
from models.race import Race
5
6
7 View Code Duplication
@dataclass
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8
class UserPastRaces:
9
    count: int
10
    num_pages: int
11
    races: List[Race]
12
13
    @staticmethod
14
    def from_dict(obj: Any) -> 'UserPastRaces':
15
        if not isinstance(obj, dict):
16
            return None
17
        count = from_int(obj.get("count"))
18
        num_pages = from_int(obj.get("num_pages"))
19
        races = from_list(Race.from_dict, obj.get("races"))
20
        return UserPastRaces(count, num_pages, races)
21
22
23
def user_past_races_from_dict(s: Any) -> UserPastRaces:
24
    return UserPastRaces.from_dict(s)
25