Skip to content

Commit

Permalink
Fix type errors and bump pypi version
Browse files Browse the repository at this point in the history
  • Loading branch information
thesadru authored Jan 13, 2024
1 parent 3b30133 commit 5570643
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 26 deletions.
2 changes: 1 addition & 1 deletion genshin/client/components/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion genshin/client/manager/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 5 additions & 5 deletions genshin/models/genshin/chronicle/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
from genshin.models.model import Aliased, APIModel

__all__ = [
"Expedition",
"TaskRewardStatus",
"TaskReward",
"AttendanceRewardStatus",
"AttendanceReward",
"AttendanceRewardStatus",
"DailyTasks",
"Notes"
"Expedition",
"Notes",
"TaskReward",
"TaskRewardStatus",
]


Expand Down
4 changes: 1 addition & 3 deletions genshin/models/genshin/chronicle/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion genshin/models/hoyolab/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
16 changes: 4 additions & 12 deletions genshin/utility/logfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down

0 comments on commit 5570643

Please sign in to comment.