From 9d85df5e48372c2db19e6cf5eea5e6939a2f0c10 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Wed, 9 Oct 2024 01:18:36 +0100 Subject: [PATCH 1/5] fix calendar needing week instead of month --- sendou/client.py | 6 +++--- sendou/models/calendarEntry.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sendou/client.py b/sendou/client.py index bc18e16..f09f144 100644 --- a/sendou/client.py +++ b/sendou/client.py @@ -76,18 +76,18 @@ async def run(): data = await self.__client.get_response(path) return User(data, self.__client) - async def get_calendar(self, year: str, month: str) -> List[CalendarEntry]: + async def get_calendar(self, year: int, week: int) -> List[CalendarEntry]: """ Get Sendou.ink calendar Attributes: year: Year - month: Month + week: Week of year Returns: (List[CalendarEntry]): Calendar Entries """ - path = CalendarEntry.api_route(year=year, month=month) + path = CalendarEntry.api_route(year=year, week=week) data = await self.__client.get_response(path) return [CalendarEntry(entry, self.__client) for entry in data] diff --git a/sendou/models/calendarEntry.py b/sendou/models/calendarEntry.py index 5d15f86..b7dfbf3 100644 --- a/sendou/models/calendarEntry.py +++ b/sendou/models/calendarEntry.py @@ -34,13 +34,13 @@ def api_route(**kwargs) -> str: """ API Route Args: - year (str): Year - month (str): Month + year (int): Year + week (int): week Returns: str: API Route """ - return f"api/calendar/{kwargs.get('year')}/{kwargs.get('month')}" + return f"api/calendar/{kwargs.get('year')}/{kwargs.get('week')}" async def get_tournament(self) -> Optional[Tournament]: """ From 070bd6bcb22f7e81995ef5cc5980332f86028350 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Wed, 9 Oct 2024 01:19:02 +0100 Subject: [PATCH 2/5] Fix typing & doc issues for standing --- sendou/models/tournament/bracket/Standing.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sendou/models/tournament/bracket/Standing.py b/sendou/models/tournament/bracket/Standing.py index 9dbdfc9..be6166d 100644 --- a/sendou/models/tournament/bracket/Standing.py +++ b/sendou/models/tournament/bracket/Standing.py @@ -10,18 +10,18 @@ class StandingStats: Attributes: set_wins (int): Set Wins - set_loses (int): Set Loses + set_losses (int): Set Loses map_wins (int): Map Wins - map_loses (int): Map Loses + map_losses (int): Map Loses points (int): Points wins_against_tied (int): Wins Against Tied buchholz_sets (Optional[int]): Buchholz Sets buchholz_maps (Optional[int]): Buchholz Maps """ set_wins: int - set_loses: int + set_losses: int map_wins: int - map_loses: int + map_losses: int points: int wins_against_tied: int buchholz_sets: Optional[int] From c2a767093610a48d7c1757f6eee6e0547645b8c4 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Wed, 9 Oct 2024 01:19:36 +0100 Subject: [PATCH 3/5] created_at can be optional for stage --- sendou/models/tournament/bracket/bracket.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sendou/models/tournament/bracket/bracket.py b/sendou/models/tournament/bracket/bracket.py index b6ed388..e04a26e 100644 --- a/sendou/models/tournament/bracket/bracket.py +++ b/sendou/models/tournament/bracket/bracket.py @@ -71,7 +71,7 @@ class BracketStage: settings (Any): Bracket Stage Settings tournament_id (int): Tournament ID type (BracketType): Bracket Type - created_at (datetime): Created At + created_at (Optional[datetime]): Created At """ id: int name: str @@ -79,7 +79,7 @@ class BracketStage: settings: BracketSettings tournament_id: int type: BracketType - created_at: datetime # Provided as unix timestamp + created_at: Optional[datetime] # Provided as unix timestamp def __init__(self, data: dict): self.id = data.get("id", 0) @@ -88,7 +88,8 @@ def __init__(self, data: dict): self.settings = BracketSettings(data.get("settings", {})) self.tournament_id = data.get("tournament_id", 0) self.type = BracketType(data.get("type", "")) - self.created_at = datetime.fromtimestamp(data.get("createdAt", 0), tz=timezone.utc) + if created_at := data.get("createdAt", 0): + self.created_at = datetime.fromtimestamp(created_at, tz=timezone.utc) class BracketGroup: @@ -199,7 +200,7 @@ class BracketMatch(BaseModel): id: int group_id: int number: int - opponent1: BracketMatchOpponent + opponent1: Optional[BracketMatchOpponent] opponent2: Optional[BracketMatchOpponent] round_id: int stage_id: int From 07aa786a0f5b24b6756de7bd4dca53c4d55a5771 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Wed, 9 Oct 2024 01:20:02 +0100 Subject: [PATCH 4/5] opponent1 can be optional in older tournaments --- sendou/models/tournament/bracket/bracket.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sendou/models/tournament/bracket/bracket.py b/sendou/models/tournament/bracket/bracket.py index e04a26e..0800fc4 100644 --- a/sendou/models/tournament/bracket/bracket.py +++ b/sendou/models/tournament/bracket/bracket.py @@ -213,7 +213,10 @@ def __init__(self, data: dict, request_client: RequestsClient): self.id = data.get("id", 0) self.group_id = data.get("group_id", 0) self.number = data.get("number", 0) - self.opponent1 = BracketMatchOpponent(data.get("opponent1", {})) + if data.get("opponent1", {}): + self.opponent1 = BracketMatchOpponent(data.get("opponent1", {})) + else: + self.opponent1 = None if data.get("opponent2", {}): self.opponent2 = BracketMatchOpponent(data.get("opponent2", {})) else: From 3dfb8e405eb9aae8e1db3f2447897f25e7c5ce0d Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Wed, 9 Oct 2024 15:08:18 +0100 Subject: [PATCH 5/5] Dump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1ffcd21..7cf0410 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "sendou-py" -version = "1.2.6" +version = "1.2.7" description = "An async Python library for Sendou.ink" authors = [ "Vincent Lee ",] license = "MIT"