From 156c42c1f3490cdf28d73e390e46e064ded44102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=E1=BA=BF=20H=C6=B0ng?= Date: Mon, 21 Oct 2024 13:33:17 +0700 Subject: [PATCH] fix: fix predownload object Wow. --- vollerei/common/api/resource.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/vollerei/common/api/resource.py b/vollerei/common/api/resource.py index 1a3e357..e6dc91a 100644 --- a/vollerei/common/api/resource.py +++ b/vollerei/common/api/resource.py @@ -1,4 +1,5 @@ from vollerei.common.enums import VoicePackLanguage +from typing import Union class Game: @@ -99,8 +100,19 @@ class PreDownload: self.major = major self.patches = patches + # Union to fix the typing issue. @staticmethod - def from_dict(data: dict) -> "PreDownload": + def from_dict(data: dict | None) -> Union["PreDownload", None]: + # pre_download can be null in the server for certain games + # e.g. HI3: + # "pre_download": null + # while in GI it is the following: + # "pre_download": { + # "major": null, + # "patches": [] + # } + if data is None: + return None return PreDownload( major=( data["major"]