fix: fix predownload object

Wow.
This commit is contained in:
2024-10-21 13:33:17 +07:00
parent 8ff2a388d7
commit 156c42c1f3

View File

@ -1,4 +1,5 @@
from vollerei.common.enums import VoicePackLanguage from vollerei.common.enums import VoicePackLanguage
from typing import Union
class Game: class Game:
@ -99,8 +100,19 @@ class PreDownload:
self.major = major self.major = major
self.patches = patches self.patches = patches
# Union to fix the typing issue.
@staticmethod @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( return PreDownload(
major=( major=(
data["major"] data["major"]