From 5570643029fcd376cd0677ed6ce5c577410d559a Mon Sep 17 00:00:00 2001 From: ashlen Date: Sat, 13 Jan 2024 19:30:59 +0000 Subject: [PATCH] Fix type errors and bump pypi version --- genshin/client/components/base.py | 2 +- genshin/client/manager/managers.py | 2 +- genshin/models/genshin/chronicle/notes.py | 10 +++++----- genshin/models/genshin/chronicle/stats.py | 4 +--- genshin/models/hoyolab/record.py | 2 +- genshin/utility/logfile.py | 16 ++++------------ pyproject.toml | 4 ++-- setup.py | 2 +- 8 files changed, 16 insertions(+), 26 deletions(-) diff --git a/genshin/client/components/base.py b/genshin/client/components/base.py index cd3040a8..a8d24137 100644 --- a/genshin/client/components/base.py +++ b/genshin/client/components/base.py @@ -26,7 +26,7 @@ class BaseClient(abc.ABC): """Base ABC Client.""" - __slots__ = ("cookie_manager", "cache", "_lang", "_region", "_default_game", "uids", "authkeys") + __slots__ = ("cookie_manager", "cache", "_lang", "_region", "_default_game", "uids", "authkeys", "_hoyolab_id") USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" # noqa: E501 diff --git a/genshin/client/manager/managers.py b/genshin/client/manager/managers.py index d88b0d1f..450b21a4 100644 --- a/genshin/client/manager/managers.py +++ b/genshin/client/manager/managers.py @@ -209,7 +209,7 @@ def multi(self) -> bool: return False @property - def jar(self) -> http.cookies.SimpleCookie[str]: + def jar(self) -> http.cookies.SimpleCookie: """SimpleCookie containing the cookies.""" return http.cookies.SimpleCookie(self.cookies) diff --git a/genshin/models/genshin/chronicle/notes.py b/genshin/models/genshin/chronicle/notes.py index ca59e84a..ea73337e 100644 --- a/genshin/models/genshin/chronicle/notes.py +++ b/genshin/models/genshin/chronicle/notes.py @@ -14,13 +14,13 @@ from genshin.models.model import Aliased, APIModel __all__ = [ - "Expedition", - "TaskRewardStatus", - "TaskReward", - "AttendanceRewardStatus", "AttendanceReward", + "AttendanceRewardStatus", "DailyTasks", - "Notes" + "Expedition", + "Notes", + "TaskReward", + "TaskRewardStatus", ] diff --git a/genshin/models/genshin/chronicle/stats.py b/genshin/models/genshin/chronicle/stats.py index 32c5c5d9..fb4d9e75 100644 --- a/genshin/models/genshin/chronicle/stats.py +++ b/genshin/models/genshin/chronicle/stats.py @@ -100,9 +100,7 @@ def __add_base_offering( offerings: typing.Sequence[typing.Any], values: typing.Dict[str, typing.Any], ) -> typing.Sequence[typing.Any]: - if values["type"] == "Reputation" and not any( - values["type"] == o["name"] for o in offerings - ): + if values["type"] == "Reputation" and not any(values["type"] == o["name"] for o in offerings): offerings = [*offerings, dict(name=values["type"], level=values["level"])] return offerings diff --git a/genshin/models/hoyolab/record.py b/genshin/models/hoyolab/record.py index 2a8e693d..c6a22648 100644 --- a/genshin/models/hoyolab/record.py +++ b/genshin/models/hoyolab/record.py @@ -159,7 +159,7 @@ def __new__(cls, **kwargs: typing.Any) -> RecordCard: elif game_id == 6: cls = StarRailRecodeCard - return super().__new__(cls) + return super().__new__(cls) # type: ignore game_id: int game_biz: str = "" diff --git a/genshin/utility/logfile.py b/genshin/utility/logfile.py index faafc079..f516b5e9 100644 --- a/genshin/utility/logfile.py +++ b/genshin/utility/logfile.py @@ -28,20 +28,12 @@ def _search_output_log(content: str) -> pathlib.Path: """Search output log for data_2.""" - match1 = re.search(r'([A-Z]:/.*?/GenshinImpact_Data)', content, re.MULTILINE) - match2 = re.search(r'([A-Z]:/.*?/YuanShen_Data)', content, re.MULTILINE) - match3 = re.search(r'([A-Z]:/.*?/StarRail_Data)', content, re.MULTILINE) - if match1 is None and match2 is None and match3 is None: + match = re.search(r"([A-Z]:/.*?/GenshinImpact_Data)", content, re.MULTILINE) + match = match or re.search(r"([A-Z]:/.*?/YuanShen_Data)", content, re.MULTILINE) + match = match or re.search(r"([A-Z]:/.*?/StarRail_Data)", content, re.MULTILINE) + if match is None: raise FileNotFoundError("No Genshin/Star Rail installation location in logfile") - match = None - if match1 is not None: - match = match1 - elif match2 is not None: - match = match2 - elif match3 is not None: - match = match3 - base_dir = pathlib.Path(match[1]) / "webCaches" webCaches = [entry for entry in base_dir.iterdir() if entry.is_dir() and entry.name.startswith("2.")] diff --git a/pyproject.toml b/pyproject.toml index fe57d030..804aafe2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,14 +24,14 @@ reportIncompatibleMethodOverride = "none" # This relies on ordering for keyword reportUnusedFunction = "none" # Makes usage of validators impossible reportPrivateUsage = "none" reportUnknownMemberType = "none" +reportUntypedFunctionDecorator = "none" +reportIncompatibleVariableOverride = "none" [tool.mypy] warn_unreachable = false disallow_untyped_defs = true ignore_missing_imports = true -install_types = true -non_interactive = true # pyright warn_unused_ignores = false diff --git a/setup.py b/setup.py index 71b2bd0e..96e87d66 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name="genshin", - version="1.6.1", + version="1.6.2", author="thesadru", author_email="thesadru@gmail.com", description="An API wrapper for Genshin Impact.",