| Conditions | 6 | 
| Total Lines | 74 | 
| Code Lines | 74 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | from dataclasses import dataclass  | 
            ||
| 157 | @staticmethod  | 
            ||
| 158 | def from_dict(obj: Any) -> 'Race':  | 
            ||
| 159 | if not isinstance(obj, dict):  | 
            ||
| 160 | return None  | 
            ||
| 161 |         name = from_str(obj.get("name")) | 
            ||
| 162 |         slug = from_str(obj.get("slug")) | 
            ||
| 163 |         status = Status.from_dict(obj.get("status")) | 
            ||
| 164 |         url = from_str(obj.get("url")) | 
            ||
| 165 |         data_url = from_str(obj.get("data_url")) | 
            ||
| 166 | websocket_url = from_union(  | 
            ||
| 167 |             [from_str, from_none], obj.get("websocket_url")) | 
            ||
| 168 | websocket_bot_url = from_union(  | 
            ||
| 169 |             [from_str, from_none], obj.get("websocket_bot_url")) | 
            ||
| 170 | websocket_oauth_url = from_union(  | 
            ||
| 171 |             [from_str, from_none], obj.get("websocket_oauth_url")) | 
            ||
| 172 |         category = RaceCategory.from_dict(obj.get("category")) | 
            ||
| 173 |         goal = Goal.from_dict(obj.get("goal")) | 
            ||
| 174 |         info = from_str(obj.get("info")) | 
            ||
| 175 |         entrants_count = from_int(obj.get("entrants_count")) | 
            ||
| 176 |         entrants_count_inactive = from_int(obj.get("entrants_count_inactive")) | 
            ||
| 177 | entrants = from_union([lambda x: from_list(  | 
            ||
| 178 |             Entrant.from_dict, x), from_none], obj.get("entrants")) | 
            ||
| 179 |         opened_at = from_datetime(obj.get("opened_at")) | 
            ||
| 180 | start_delay = from_union(  | 
            ||
| 181 |             [from_timedelta, from_none], obj.get("start_delay")) | 
            ||
| 182 | started_at = from_union(  | 
            ||
| 183 |             [from_datetime, from_none], (obj.get("started_at"))) | 
            ||
| 184 | ended_at = from_union([from_datetime, from_none],  | 
            ||
| 185 |                               (obj.get("ended_at"))) | 
            ||
| 186 | cancelled_at = from_union(  | 
            ||
| 187 |             [from_datetime, from_none], (obj.get("cancelled_at"))) | 
            ||
| 188 |         unlisted = from_union([from_bool, from_none], obj.get("unlisted")) | 
            ||
| 189 |         time_limit = from_timedelta(obj.get("time_limit")) | 
            ||
| 190 | streaming_required = from_union(  | 
            ||
| 191 |             [from_bool, from_none], obj.get("streaming_required")) | 
            ||
| 192 |         auto_start = from_union([from_bool, from_none], obj.get("auto_start")) | 
            ||
| 193 | opened_by = from_union(  | 
            ||
| 194 |             [lambda x: User.from_dict(x), from_none], obj.get("opened_by")) | 
            ||
| 195 | monitors = from_union([lambda x: from_list(  | 
            ||
| 196 |             User.from_dict, x), from_none], obj.get("monitors")) | 
            ||
| 197 |         recordable = from_union([from_bool, from_none], obj.get("recordable")) | 
            ||
| 198 |         recorded = from_union([from_bool, from_none], obj.get("recorded")) | 
            ||
| 199 | recorded_by = from_union(  | 
            ||
| 200 |             [lambda x: User.from_dict(x), from_none], obj.get("recorded_by")) | 
            ||
| 201 | allow_comments = from_union(  | 
            ||
| 202 |             [from_bool, from_none], obj.get("allow_comments")) | 
            ||
| 203 | hide_comments = from_union(  | 
            ||
| 204 |             [from_bool, from_none], obj.get("hide_comments")) | 
            ||
| 205 | allow_midrace_chat = from_union(  | 
            ||
| 206 |             [from_bool, from_none], obj.get("allow_midrace_chat")) | 
            ||
| 207 | allow_non_entrant_chat = from_union(  | 
            ||
| 208 |             [from_bool, from_none], obj.get("allow_non_entrant_chat")) | 
            ||
| 209 | chat_message_delay = from_union(  | 
            ||
| 210 |             [from_str, from_none], obj.get("chat_message_delay")) | 
            ||
| 211 |         version = from_union([from_int, from_none], obj.get("version")) | 
            ||
| 212 | entrants_count_finished = from_union(  | 
            ||
| 213 |             [from_int, from_none], obj.get("entrants_count_finished")) | 
            ||
| 214 | return Race(  | 
            ||
| 215 | name=name, status=status, url=url, data_url=data_url,  | 
            ||
| 216 | websocket_url=websocket_url, websocket_bot_url=websocket_bot_url,  | 
            ||
| 217 | websocket_oauth_url=websocket_oauth_url, category=category,  | 
            ||
| 218 | goal=goal, info=info, entrants_count=entrants_count,  | 
            ||
| 219 | entrants_count_inactive=entrants_count_inactive,  | 
            ||
| 220 | opened_at=opened_at, time_limit=time_limit, entrants=entrants,  | 
            ||
| 221 | version=version, started_at=started_at, ended_at=ended_at,  | 
            ||
| 222 | cancelled_at=cancelled_at, unlisted=unlisted,  | 
            ||
| 223 | streaming_required=streaming_required, auto_start=auto_start,  | 
            ||
| 224 | opened_by=opened_by, monitors=monitors, recordable=recordable,  | 
            ||
| 225 | recorded=recorded, recorded_by=recorded_by,  | 
            ||
| 226 | allow_comments=allow_comments, hide_comments=hide_comments,  | 
            ||
| 227 | allow_midrace_chat=allow_midrace_chat,  | 
            ||
| 228 | allow_non_entrant_chat=allow_non_entrant_chat,  | 
            ||
| 229 | chat_message_delay=chat_message_delay, start_delay=start_delay,  | 
            ||
| 230 | entrants_count_finished=entrants_count_finished, slug=slug  | 
            ||
| 231 | )  | 
            ||
| 245 |