diff --git a/.flake8 b/.flake8 index c39efc79..eb1a7f74 100644 --- a/.flake8 +++ b/.flake8 @@ -6,6 +6,7 @@ exclude = tests, test.py # D105: Missing docstring in magic method # D106: Missing docstring Model.Config # D419: Docstring is empty +# E704: Multiple statements on one line (def) # S101: Use of assert for type checking # S303: Use of md5 # S311: Use of pseudo-random generators @@ -14,7 +15,8 @@ exclude = tests, test.py ignore = A001, A002, A003, C408, - D105, D106, D419 + D105, D106, D419, + E704, S101, S303, S311, S324, W503, diff --git a/genshin/__init__.py b/genshin/__init__.py index 66b92d77..a5a9ffb9 100644 --- a/genshin/__init__.py +++ b/genshin/__init__.py @@ -6,6 +6,7 @@ Source Code: https://github.com/thesadru/genshin.py """ + from . import models, utility from .client import * from .constants import * diff --git a/genshin/__main__.py b/genshin/__main__.py index 629ed987..2f7e8f3a 100644 --- a/genshin/__main__.py +++ b/genshin/__main__.py @@ -1,4 +1,5 @@ """CLI tools.""" + import asyncio import datetime import functools diff --git a/genshin/client/__init__.py b/genshin/client/__init__.py index b955bcc9..9faaf5c5 100644 --- a/genshin/client/__init__.py +++ b/genshin/client/__init__.py @@ -1,4 +1,5 @@ """Default client implementation.""" + from . import components from .cache import * from .clients import * diff --git a/genshin/client/cache.py b/genshin/client/cache.py index fbd42b29..1138c1d8 100644 --- a/genshin/client/cache.py +++ b/genshin/client/cache.py @@ -1,4 +1,5 @@ """Cache for client.""" + from __future__ import annotations import abc diff --git a/genshin/client/clients.py b/genshin/client/clients.py index a4b426e6..87e8aa9d 100644 --- a/genshin/client/clients.py +++ b/genshin/client/clients.py @@ -1,4 +1,5 @@ """A simple HTTP client for API endpoints.""" + from .components import ( calculator, chronicle, diff --git a/genshin/client/compatibility.py b/genshin/client/compatibility.py index 4ed9e1be..ce4d8fc2 100644 --- a/genshin/client/compatibility.py +++ b/genshin/client/compatibility.py @@ -1,4 +1,5 @@ """Reverse-compatibility layer for previous versions.""" + from __future__ import annotations import typing diff --git a/genshin/client/components/base.py b/genshin/client/components/base.py index a8d24137..49673cf9 100644 --- a/genshin/client/components/base.py +++ b/genshin/client/components/base.py @@ -1,4 +1,5 @@ """Base ABC Client.""" + import abc import asyncio import base64 diff --git a/genshin/client/components/calculator/__init__.py b/genshin/client/components/calculator/__init__.py index 8c47acf1..b8770c14 100644 --- a/genshin/client/components/calculator/__init__.py +++ b/genshin/client/components/calculator/__init__.py @@ -1,2 +1,3 @@ """Calculator client.""" + from .client import * diff --git a/genshin/client/components/calculator/calculator.py b/genshin/client/components/calculator/calculator.py index 6ac2ba7f..435bd755 100644 --- a/genshin/client/components/calculator/calculator.py +++ b/genshin/client/components/calculator/calculator.py @@ -2,6 +2,7 @@ Over-engineered for the sake of extendability and maintainability. """ + from __future__ import annotations import abc diff --git a/genshin/client/components/calculator/client.py b/genshin/client/components/calculator/client.py index 5140f9c0..a629ab84 100644 --- a/genshin/client/components/calculator/client.py +++ b/genshin/client/components/calculator/client.py @@ -1,4 +1,5 @@ """Calculator client.""" + from __future__ import annotations import asyncio diff --git a/genshin/client/components/chronicle/__init__.py b/genshin/client/components/chronicle/__init__.py index 30fb3fc8..076cfcbe 100644 --- a/genshin/client/components/chronicle/__init__.py +++ b/genshin/client/components/chronicle/__init__.py @@ -1,2 +1,3 @@ """Battle chronicle client components.""" + from .client import * diff --git a/genshin/client/components/chronicle/client.py b/genshin/client/components/chronicle/client.py index a8a2eca3..94f31407 100644 --- a/genshin/client/components/chronicle/client.py +++ b/genshin/client/components/chronicle/client.py @@ -1,4 +1,5 @@ """Battle chronicle component.""" + from . import genshin, honkai, starrail __all__ = ["BattleChronicleClient"] diff --git a/genshin/client/components/chronicle/starrail.py b/genshin/client/components/chronicle/starrail.py index 57cbedb6..b1935341 100644 --- a/genshin/client/components/chronicle/starrail.py +++ b/genshin/client/components/chronicle/starrail.py @@ -1,4 +1,5 @@ """StarRail battle chronicle component.""" + import asyncio import typing @@ -126,3 +127,15 @@ async def get_starrail_rogue( payload = dict(schedule_type=schedule_type, need_detail="true") data = await self._request_starrail_record("rogue", uid, lang=lang, payload=payload) return models.StarRailRogue(**data) + + async def get_starrail_pure_fiction( + self, + uid: typing.Optional[int] = None, + *, + previous: bool = False, + lang: typing.Optional[str] = None, + ) -> models.StarRailPureFiction: + """Get starrail pure fiction runs.""" + payload = dict(schedule_type=2 if previous else 1, need_all="true") + data = await self._request_starrail_record("challenge_story", uid, lang=lang, payload=payload) + return models.StarRailPureFiction(**data) diff --git a/genshin/client/components/daily.py b/genshin/client/components/daily.py index b9ca2964..53981d29 100644 --- a/genshin/client/components/daily.py +++ b/genshin/client/components/daily.py @@ -1,4 +1,5 @@ """Daily reward component.""" + import asyncio import datetime import functools @@ -150,8 +151,7 @@ async def claim_daily_reward( # noqa: D102 missing docstring in overload? lang: typing.Optional[str] = None, reward: typing.Literal[True] = ..., challenge: typing.Optional[typing.Mapping[str, str]] = None, - ) -> models.DailyReward: - ... + ) -> models.DailyReward: ... @typing.overload async def claim_daily_reward( # noqa: D102 missing docstring in overload? @@ -161,8 +161,7 @@ async def claim_daily_reward( # noqa: D102 missing docstring in overload? lang: typing.Optional[str] = None, reward: typing.Literal[False], challenge: typing.Optional[typing.Mapping[str, str]] = None, - ) -> None: - ... + ) -> None: ... async def claim_daily_reward( self, diff --git a/genshin/client/components/diary.py b/genshin/client/components/diary.py index f175d1bd..02b6d042 100644 --- a/genshin/client/components/diary.py +++ b/genshin/client/components/diary.py @@ -1,4 +1,5 @@ """Diary component.""" + import datetime import functools import typing diff --git a/genshin/client/components/gacha.py b/genshin/client/components/gacha.py index 71e27dfc..fe6cad62 100644 --- a/genshin/client/components/gacha.py +++ b/genshin/client/components/gacha.py @@ -1,4 +1,5 @@ """Wish component.""" + import asyncio import functools import typing diff --git a/genshin/client/components/geetest/__init__.py b/genshin/client/components/geetest/__init__.py index 97d622bd..3871455b 100644 --- a/genshin/client/components/geetest/__init__.py +++ b/genshin/client/components/geetest/__init__.py @@ -2,4 +2,5 @@ Credits to M-307 - https://github.com/mrwan200 """ + from .client import * diff --git a/genshin/client/components/geetest/client.py b/genshin/client/components/geetest/client.py index 898a4d23..036fa4b4 100644 --- a/genshin/client/components/geetest/client.py +++ b/genshin/client/components/geetest/client.py @@ -1,4 +1,5 @@ """Geetest client component.""" + import json import typing diff --git a/genshin/client/components/geetest/server.py b/genshin/client/components/geetest/server.py index 639c3fc9..a8bb641b 100644 --- a/genshin/client/components/geetest/server.py +++ b/genshin/client/components/geetest/server.py @@ -1,4 +1,5 @@ """Aiohttp webserver used for captcha solving and email verification.""" + from __future__ import annotations import asyncio diff --git a/genshin/client/components/hoyolab.py b/genshin/client/components/hoyolab.py index eef52a91..7e1804dc 100644 --- a/genshin/client/components/hoyolab.py +++ b/genshin/client/components/hoyolab.py @@ -1,4 +1,5 @@ """Hoyolab component.""" + import asyncio import typing diff --git a/genshin/client/components/lineup.py b/genshin/client/components/lineup.py index bc71ae7f..69326e3d 100644 --- a/genshin/client/components/lineup.py +++ b/genshin/client/components/lineup.py @@ -1,4 +1,5 @@ """Lineup component.""" + import functools import typing diff --git a/genshin/client/components/teapot.py b/genshin/client/components/teapot.py index e58e9c25..b3a75252 100644 --- a/genshin/client/components/teapot.py +++ b/genshin/client/components/teapot.py @@ -1,4 +1,5 @@ """Teapot component.""" + import functools import typing diff --git a/genshin/client/components/transaction.py b/genshin/client/components/transaction.py index 010e9bee..73dcd9cb 100644 --- a/genshin/client/components/transaction.py +++ b/genshin/client/components/transaction.py @@ -1,4 +1,5 @@ """Transaction client.""" + import functools import typing import urllib.parse diff --git a/genshin/client/components/wiki.py b/genshin/client/components/wiki.py index fbe1bb9c..5320fa46 100644 --- a/genshin/client/components/wiki.py +++ b/genshin/client/components/wiki.py @@ -1,4 +1,5 @@ """Wiki component.""" + import typing from genshin import types @@ -34,8 +35,7 @@ async def get_wiki_previews( # noqa: D102 missing docstring in overload? menu: typing.Literal[models.WikiPageType.CHARACTER], *, lang: typing.Optional[str] = None, - ) -> typing.Sequence[models.CharacterPreview]: - ... + ) -> typing.Sequence[models.CharacterPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? @@ -43,8 +43,7 @@ async def get_wiki_previews( # noqa: D102 missing docstring in overload? menu: typing.Literal[models.WikiPageType.WEAPON], *, lang: typing.Optional[str] = None, - ) -> typing.Sequence[models.WeaponPreview]: - ... + ) -> typing.Sequence[models.WeaponPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? @@ -52,8 +51,7 @@ async def get_wiki_previews( # noqa: D102 missing docstring in overload? menu: typing.Literal[models.WikiPageType.ARTIFACT], *, lang: typing.Optional[str] = None, - ) -> typing.Sequence[models.ArtifactPreview]: - ... + ) -> typing.Sequence[models.ArtifactPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? @@ -61,8 +59,7 @@ async def get_wiki_previews( # noqa: D102 missing docstring in overload? menu: typing.Literal[models.WikiPageType.ENEMY], *, lang: typing.Optional[str] = None, - ) -> typing.Sequence[models.EnemyPreview]: - ... + ) -> typing.Sequence[models.EnemyPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? @@ -70,8 +67,7 @@ async def get_wiki_previews( # noqa: D102 missing docstring in overload? menu: int, *, lang: typing.Optional[str] = None, - ) -> typing.Sequence[models.BaseWikiPreview]: - ... + ) -> typing.Sequence[models.BaseWikiPreview]: ... async def get_wiki_previews( self, diff --git a/genshin/client/manager/__init__.py b/genshin/client/manager/__init__.py index 5520a866..070264a0 100644 --- a/genshin/client/manager/__init__.py +++ b/genshin/client/manager/__init__.py @@ -1,3 +1,4 @@ """Cookie managers.""" + from .cookie import * from .managers import * diff --git a/genshin/client/manager/cookie.py b/genshin/client/manager/cookie.py index 1780de6e..a2b59d0c 100644 --- a/genshin/client/manager/cookie.py +++ b/genshin/client/manager/cookie.py @@ -15,6 +15,7 @@ - stoken (v2) + mid -> ltoken_v2 (token_type=2) - stoken (v2) + mid -> cookie_token_v2 (token_type=4) """ + from __future__ import annotations import typing diff --git a/genshin/client/manager/managers.py b/genshin/client/manager/managers.py index fceb4ca5..0e33324b 100644 --- a/genshin/client/manager/managers.py +++ b/genshin/client/manager/managers.py @@ -1,4 +1,5 @@ """Cookie managers for making authenticated requests.""" + from __future__ import annotations import abc diff --git a/genshin/client/ratelimit.py b/genshin/client/ratelimit.py index c5385400..61ef328d 100644 --- a/genshin/client/ratelimit.py +++ b/genshin/client/ratelimit.py @@ -1,4 +1,5 @@ """Ratelimit handlers.""" + import asyncio import functools import typing diff --git a/genshin/client/routes.py b/genshin/client/routes.py index e4804618..becf0e37 100644 --- a/genshin/client/routes.py +++ b/genshin/client/routes.py @@ -1,4 +1,5 @@ """API routes.""" + import abc import typing diff --git a/genshin/constants.py b/genshin/constants.py index 800d6012..2d86a6ff 100644 --- a/genshin/constants.py +++ b/genshin/constants.py @@ -1,4 +1,5 @@ """Constants hardcoded for optimizations.""" + from . import types __all__ = ["LANGS"] diff --git a/genshin/errors.py b/genshin/errors.py index de22d3b4..1ea5e1e2 100644 --- a/genshin/errors.py +++ b/genshin/errors.py @@ -1,4 +1,5 @@ """Errors received from the API.""" + import typing __all__ = [ diff --git a/genshin/models/__init__.py b/genshin/models/__init__.py index 5fb96b34..35edc5e7 100644 --- a/genshin/models/__init__.py +++ b/genshin/models/__init__.py @@ -1,4 +1,5 @@ """API models.""" + from .genshin import * from .honkai import * from .hoyolab import * diff --git a/genshin/models/genshin/__init__.py b/genshin/models/genshin/__init__.py index e841f5a4..248c29cc 100644 --- a/genshin/models/genshin/__init__.py +++ b/genshin/models/genshin/__init__.py @@ -1,4 +1,5 @@ """Genshin models.""" + from .calculator import * from .character import * from .chronicle import * diff --git a/genshin/models/genshin/calculator.py b/genshin/models/genshin/calculator.py index d7c258fb..4e871f13 100644 --- a/genshin/models/genshin/calculator.py +++ b/genshin/models/genshin/calculator.py @@ -1,4 +1,5 @@ """Genshin calculator models.""" + from __future__ import annotations import collections diff --git a/genshin/models/genshin/chronicle/__init__.py b/genshin/models/genshin/chronicle/__init__.py index 5fc8848c..094b8f71 100644 --- a/genshin/models/genshin/chronicle/__init__.py +++ b/genshin/models/genshin/chronicle/__init__.py @@ -1,4 +1,5 @@ """Battle chronicle models.""" + from .abyss import * from .activities import * from .characters import * diff --git a/genshin/models/genshin/chronicle/activities.py b/genshin/models/genshin/chronicle/activities.py index 2f9535d5..bb2b3931 100644 --- a/genshin/models/genshin/chronicle/activities.py +++ b/genshin/models/genshin/chronicle/activities.py @@ -1,4 +1,5 @@ """Chronicle activities models.""" + import datetime import re import typing diff --git a/genshin/models/genshin/chronicle/notes.py b/genshin/models/genshin/chronicle/notes.py index ea73337e..c9c52ac8 100644 --- a/genshin/models/genshin/chronicle/notes.py +++ b/genshin/models/genshin/chronicle/notes.py @@ -1,4 +1,5 @@ """Genshin chronicle notes.""" + import datetime import enum import typing diff --git a/genshin/models/genshin/chronicle/tcg.py b/genshin/models/genshin/chronicle/tcg.py index d2d5b934..ea1ec1dc 100644 --- a/genshin/models/genshin/chronicle/tcg.py +++ b/genshin/models/genshin/chronicle/tcg.py @@ -1,4 +1,5 @@ """Genshin serenitea pot replica display models.""" + from __future__ import annotations import enum diff --git a/genshin/models/genshin/constants.py b/genshin/models/genshin/constants.py index 8b8dd8ef..3b5cc134 100644 --- a/genshin/models/genshin/constants.py +++ b/genshin/models/genshin/constants.py @@ -1,4 +1,5 @@ """Genshin model constants.""" + import typing __all__ = ["CHARACTER_NAMES", "DBChar"] diff --git a/genshin/models/genshin/daily.py b/genshin/models/genshin/daily.py index c21854b0..1b2e2443 100644 --- a/genshin/models/genshin/daily.py +++ b/genshin/models/genshin/daily.py @@ -1,4 +1,5 @@ """Daily reward models.""" + import calendar import datetime import typing diff --git a/genshin/models/genshin/diary.py b/genshin/models/genshin/diary.py index d34617f5..afe27314 100644 --- a/genshin/models/genshin/diary.py +++ b/genshin/models/genshin/diary.py @@ -1,4 +1,5 @@ """Genshin diary models.""" + import datetime import enum import typing diff --git a/genshin/models/genshin/gacha.py b/genshin/models/genshin/gacha.py index 01bd0fdd..777b32a3 100644 --- a/genshin/models/genshin/gacha.py +++ b/genshin/models/genshin/gacha.py @@ -1,4 +1,5 @@ """Genshin wish models.""" + import datetime import enum import re diff --git a/genshin/models/genshin/lineup.py b/genshin/models/genshin/lineup.py index 5090601b..6ae71946 100644 --- a/genshin/models/genshin/lineup.py +++ b/genshin/models/genshin/lineup.py @@ -1,4 +1,5 @@ """Genshin lineup models.""" + from __future__ import annotations import datetime diff --git a/genshin/models/genshin/teapot.py b/genshin/models/genshin/teapot.py index 543c0216..c12e3c90 100644 --- a/genshin/models/genshin/teapot.py +++ b/genshin/models/genshin/teapot.py @@ -1,4 +1,5 @@ """Genshin serenitea pot replica display models.""" + from __future__ import annotations import datetime diff --git a/genshin/models/genshin/wiki.py b/genshin/models/genshin/wiki.py index a37d92fb..d1898455 100644 --- a/genshin/models/genshin/wiki.py +++ b/genshin/models/genshin/wiki.py @@ -1,4 +1,5 @@ """Genshin wish models.""" + import enum import json import typing diff --git a/genshin/models/honkai/__init__.py b/genshin/models/honkai/__init__.py index 36ec2f19..3d8f5c8f 100644 --- a/genshin/models/honkai/__init__.py +++ b/genshin/models/honkai/__init__.py @@ -1,4 +1,5 @@ """Honkai models.""" + from .battlesuit import * from .chronicle import * from .constants import * diff --git a/genshin/models/honkai/battlesuit.py b/genshin/models/honkai/battlesuit.py index cbc8ef6b..e77fbe34 100644 --- a/genshin/models/honkai/battlesuit.py +++ b/genshin/models/honkai/battlesuit.py @@ -1,4 +1,5 @@ """Honkai battlesuit model.""" + import logging import re import typing diff --git a/genshin/models/honkai/chronicle/__init__.py b/genshin/models/honkai/chronicle/__init__.py index fcf46466..d5698270 100644 --- a/genshin/models/honkai/chronicle/__init__.py +++ b/genshin/models/honkai/chronicle/__init__.py @@ -1,4 +1,5 @@ """Battle chronicle models.""" + from .battlesuits import * from .modes import * from .stats import * diff --git a/genshin/models/honkai/chronicle/battlesuits.py b/genshin/models/honkai/chronicle/battlesuits.py index eb08661e..6fec9c9d 100644 --- a/genshin/models/honkai/chronicle/battlesuits.py +++ b/genshin/models/honkai/chronicle/battlesuits.py @@ -1,4 +1,5 @@ """Honkai chronicle battlesuits.""" + import re import typing diff --git a/genshin/models/honkai/chronicle/modes.py b/genshin/models/honkai/chronicle/modes.py index 3ba35625..92067ebd 100644 --- a/genshin/models/honkai/chronicle/modes.py +++ b/genshin/models/honkai/chronicle/modes.py @@ -1,4 +1,5 @@ """Honkai battle chronicle models.""" + from __future__ import annotations import datetime diff --git a/genshin/models/honkai/chronicle/stats.py b/genshin/models/honkai/chronicle/stats.py index 43d9d513..b7f57490 100644 --- a/genshin/models/honkai/chronicle/stats.py +++ b/genshin/models/honkai/chronicle/stats.py @@ -1,4 +1,5 @@ """Honkai stats models.""" + import typing if typing.TYPE_CHECKING: diff --git a/genshin/models/honkai/constants.py b/genshin/models/honkai/constants.py index f793e5a8..3f644fa4 100644 --- a/genshin/models/honkai/constants.py +++ b/genshin/models/honkai/constants.py @@ -1,4 +1,5 @@ """Honkai model constants.""" + import typing __all__ = ["BATTLESUIT_IDENTIFIERS"] diff --git a/genshin/models/hoyolab/__init__.py b/genshin/models/hoyolab/__init__.py index b11f0436..9a911330 100644 --- a/genshin/models/hoyolab/__init__.py +++ b/genshin/models/hoyolab/__init__.py @@ -1,4 +1,5 @@ """Hoyolab models.""" + from .announcements import * from .private import * from .record import * diff --git a/genshin/models/hoyolab/record.py b/genshin/models/hoyolab/record.py index c6a22648..e47225d4 100644 --- a/genshin/models/hoyolab/record.py +++ b/genshin/models/hoyolab/record.py @@ -1,4 +1,5 @@ """Base hoyolab APIModels.""" + from __future__ import annotations import enum diff --git a/genshin/models/model.py b/genshin/models/model.py index c930eba5..9f80e7f3 100644 --- a/genshin/models/model.py +++ b/genshin/models/model.py @@ -1,4 +1,5 @@ """Modified pydantic model.""" + from __future__ import annotations import abc diff --git a/genshin/models/starrail/__init__.py b/genshin/models/starrail/__init__.py index 5f44a33b..2ecf1bf2 100644 --- a/genshin/models/starrail/__init__.py +++ b/genshin/models/starrail/__init__.py @@ -1,3 +1,4 @@ """Starrail models.""" + from .character import * from .chronicle import * diff --git a/genshin/models/starrail/character.py b/genshin/models/starrail/character.py index dc943f6e..1f311bd8 100644 --- a/genshin/models/starrail/character.py +++ b/genshin/models/starrail/character.py @@ -1,4 +1,5 @@ """Starrail base character model.""" + from genshin.models.model import APIModel, Unique diff --git a/genshin/models/starrail/chronicle/base.py b/genshin/models/starrail/chronicle/base.py index 97645018..0bd44af5 100644 --- a/genshin/models/starrail/chronicle/base.py +++ b/genshin/models/starrail/chronicle/base.py @@ -1,4 +1,5 @@ """Starrail Chronicle Base Model.""" + import datetime from genshin.models.model import APIModel diff --git a/genshin/models/starrail/chronicle/challenge.py b/genshin/models/starrail/chronicle/challenge.py index 18510312..b985ecf8 100644 --- a/genshin/models/starrail/chronicle/challenge.py +++ b/genshin/models/starrail/chronicle/challenge.py @@ -1,12 +1,29 @@ """Starrail chronicle challenge.""" -from typing import List + +from typing import TYPE_CHECKING, Any, Dict, List + +if TYPE_CHECKING: + import pydantic.v1 as pydantic +else: + try: + import pydantic.v1 as pydantic + except ImportError: + import pydantic from genshin.models.model import Aliased, APIModel from genshin.models.starrail.character import FloorCharacter from .base import PartialTime -__all__ = ["FloorNode", "StarRailChallenge", "StarRailFloor"] +__all__ = [ + "FictionBuff", + "FictionFloor", + "FictionFloorNode", + "FloorNode", + "StarRailChallenge", + "StarRailFloor", + "StarRailPureFiction", +] class FloorNode(APIModel): @@ -40,3 +57,65 @@ class StarRailChallenge(APIModel): has_data: bool floors: List[StarRailFloor] = Aliased("all_floor_detail") + + +class FictionBuff(APIModel): + """Buff for a Pure Fiction floor.""" + + id: int + name: str = Aliased("name_mi18n") + description: str = Aliased("desc_mi18n") + icon: str + + +class FictionFloorNode(FloorNode): + """Node for a Pure Fiction floor.""" + + buff: FictionBuff + score: int + + +class FictionFloor(APIModel): + """Floor in a Pure Fiction challenge.""" + + id: int = Aliased("maze_id") + name: str + round_num: int + star_num: int + node_1: FictionFloorNode + node_2: FictionFloorNode + is_fast: bool + + @property + def score(self) -> int: + """Total score of the floor.""" + return self.node_1.score + self.node_2.score + + +class StarRailPureFiction(APIModel): + """Pure Fiction challenge in a season.""" + + name: str + season_id: int + begin_time: PartialTime + end_time: PartialTime + + total_stars: int = Aliased("star_num") + max_floor: str + total_battles: int = Aliased("battle_num") + has_data: bool + + floors: List[FictionFloor] = Aliased("all_floor_detail") + max_floor_id: int + + @pydantic.root_validator(pre=True) + def __unnest_groups(cls, values: Dict[str, Any]) -> Dict[str, Any]: + if "groups" in values and isinstance(values["groups"], List): + groups: List[Dict[str, Any]] = values["groups"] + if len(groups) > 0: + values["name"] = groups[0]["name_mi18n"] + values["season_id"] = groups[0]["schedule_id"] + values["begin_time"] = groups[0]["begin_time"] + values["end_time"] = groups[0]["end_time"] + + return values diff --git a/genshin/models/starrail/chronicle/characters.py b/genshin/models/starrail/chronicle/characters.py index bf8d4c55..f6d3bde3 100644 --- a/genshin/models/starrail/chronicle/characters.py +++ b/genshin/models/starrail/chronicle/characters.py @@ -1,4 +1,5 @@ """Starrail chronicle character.""" + from typing import List, Optional from genshin.models.model import APIModel diff --git a/genshin/models/starrail/chronicle/notes.py b/genshin/models/starrail/chronicle/notes.py index 59e03c21..d3fa8f8e 100644 --- a/genshin/models/starrail/chronicle/notes.py +++ b/genshin/models/starrail/chronicle/notes.py @@ -1,4 +1,5 @@ """Starrail chronicle notes.""" + import datetime import typing diff --git a/genshin/models/starrail/chronicle/rogue.py b/genshin/models/starrail/chronicle/rogue.py index 9a034e95..ea2b5329 100644 --- a/genshin/models/starrail/chronicle/rogue.py +++ b/genshin/models/starrail/chronicle/rogue.py @@ -1,4 +1,5 @@ """Starrail Rogue models.""" + from typing import List from genshin.models.model import APIModel diff --git a/genshin/models/starrail/chronicle/stats.py b/genshin/models/starrail/chronicle/stats.py index 89aa17c8..c25a17ba 100644 --- a/genshin/models/starrail/chronicle/stats.py +++ b/genshin/models/starrail/chronicle/stats.py @@ -1,4 +1,5 @@ """Starrail chronicle stats.""" + import typing from genshin.models.model import Aliased, APIModel diff --git a/genshin/paginators/__init__.py b/genshin/paginators/__init__.py index 8afc4e8a..468a0250 100644 --- a/genshin/paginators/__init__.py +++ b/genshin/paginators/__init__.py @@ -1,3 +1,4 @@ """Fancy paginators with a large amount of useful methods.""" + from .api import * from .base import * diff --git a/genshin/paginators/api.py b/genshin/paginators/api.py index 217665a9..8201a84f 100644 --- a/genshin/paginators/api.py +++ b/genshin/paginators/api.py @@ -1,4 +1,5 @@ """Base paginators made specifically for interaction with the api.""" + from __future__ import annotations import abc diff --git a/genshin/paginators/base.py b/genshin/paginators/base.py index 4eff9bae..cf5be77e 100644 --- a/genshin/paginators/base.py +++ b/genshin/paginators/base.py @@ -91,8 +91,7 @@ def __await__(self) -> typing.Generator[None, None, typing.Sequence[T]]: return self.flatten().__await__() @abc.abstractmethod - async def __anext__(self) -> T: - ... + async def __anext__(self) -> T: ... class BasicPaginator(typing.Generic[T], Paginator[T], abc.ABC): diff --git a/genshin/types.py b/genshin/types.py index c1ced452..9b87fd9c 100644 --- a/genshin/types.py +++ b/genshin/types.py @@ -1,4 +1,5 @@ """Types used in the library.""" + import enum import typing diff --git a/genshin/utility/__init__.py b/genshin/utility/__init__.py index b2254923..cd1e07c3 100644 --- a/genshin/utility/__init__.py +++ b/genshin/utility/__init__.py @@ -1,4 +1,5 @@ """Utilities for genshin.py.""" + from . import geetest from .concurrency import * from .ds import * diff --git a/genshin/utility/concurrency.py b/genshin/utility/concurrency.py index 9e6d0967..681a5cf5 100644 --- a/genshin/utility/concurrency.py +++ b/genshin/utility/concurrency.py @@ -1,4 +1,5 @@ """Utilities for concurrency optimizations.""" + from __future__ import annotations import asyncio diff --git a/genshin/utility/deprecation.py b/genshin/utility/deprecation.py index 0d06fd1d..c99d9bb1 100644 --- a/genshin/utility/deprecation.py +++ b/genshin/utility/deprecation.py @@ -1,4 +1,5 @@ """Deprecation decorator.""" + import functools import inspect import typing diff --git a/genshin/utility/ds.py b/genshin/utility/ds.py index 8f9466d5..1cd169f5 100644 --- a/genshin/utility/ds.py +++ b/genshin/utility/ds.py @@ -1,4 +1,5 @@ """Dynamic secret generation.""" + import hashlib import json import random diff --git a/genshin/utility/fs.py b/genshin/utility/fs.py index feac290a..51f33186 100644 --- a/genshin/utility/fs.py +++ b/genshin/utility/fs.py @@ -1,4 +1,5 @@ """File system related utilities.""" + import functools import pathlib import tempfile diff --git a/genshin/utility/geetest.py b/genshin/utility/geetest.py index 4d535d7d..300ba2ae 100644 --- a/genshin/utility/geetest.py +++ b/genshin/utility/geetest.py @@ -1,4 +1,5 @@ """Geetest utilities.""" + import base64 import json import typing diff --git a/genshin/utility/logfile.py b/genshin/utility/logfile.py index f516b5e9..f0b6719b 100644 --- a/genshin/utility/logfile.py +++ b/genshin/utility/logfile.py @@ -1,4 +1,5 @@ """Search logfile for authkeys.""" + import pathlib import re import typing diff --git a/genshin/utility/uid.py b/genshin/utility/uid.py index 132aece9..e0fabcae 100644 --- a/genshin/utility/uid.py +++ b/genshin/utility/uid.py @@ -1,4 +1,5 @@ """Utility functions related to genshin.""" + import typing from genshin import types diff --git a/noxfile.py b/noxfile.py index 9f5c0ea1..550a0401 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,4 +1,5 @@ """Nox file.""" + from __future__ import annotations import logging diff --git a/tests/models/test_model.py b/tests/models/test_model.py index 50897a6e..c9978389 100644 --- a/tests/models/test_model.py +++ b/tests/models/test_model.py @@ -6,8 +6,7 @@ import genshin -class LiteralCharacter(genshin.models.BaseCharacter): - ... +class LiteralCharacter(genshin.models.BaseCharacter): ... LiteralCharacter.__pre_root_validators__ = LiteralCharacter.__pre_root_validators__[:-1]