Skip to content

Commit

Permalink
Fix incompatible variable assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Aug 25, 2024
1 parent 1e5565f commit 8266e75
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions genshin/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, _frame: int = 1, **data: typing.Any) -> None:
super().__init__(**data, lang=lang)

for name in self.model_fields.keys():
value = getattr(self, name)
value = getattr(self, name, None)
if isinstance(value, APIModel):
object.__setattr__(value, "lang", self.lang)

Expand Down Expand Up @@ -143,10 +143,9 @@ def __parse_timezones(self) -> "APIModel":
and isinstance(field.json_schema_extra, dict)
):
timezone = field.json_schema_extra.get("timezone", 0)
if isinstance(timezone, int):
timezone = datetime.timezone(datetime.timedelta(hours=timezone))
if isinstance(timezone, datetime.timezone):
setattr(self, name, value.replace(tzinfo=timezone))
tzinfo = datetime.timezone(datetime.timedelta(hours=timezone)) if isinstance(timezone, int) else None
if isinstance(tzinfo, datetime.timezone):
setattr(self, name, value.replace(tzinfo=tzinfo))

return self

Expand Down Expand Up @@ -184,7 +183,7 @@ def _get_mi18n(
if not field.json_schema_extra.get("mi18n"):
raise TypeError(f"{field!r} does not have mi18n.")

key = field.json_schema_extra["mi18n"]
key = str(field.json_schema_extra["mi18n"])
default = default or field.alias

if key not in self._mi18n:
Expand Down

0 comments on commit 8266e75

Please sign in to comment.