Skip to content

Commit 025db0b

Browse files
authored
fix generator return typing + add clan_tag to war class
would break on runtime, when trying to use the fw api, but generator typing fixed - needed 3 parameters & only had 1. also added clan_tag to war_class, because the response doesn't specify clan & opponent, so the class needs the tag to do so
1 parent eaed824 commit 025db0b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

coc/ext/fullwarapi/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ async def war_result(self, clan_tag: str, preparation_start: int = 0) -> Optiona
168168
f"/war_result?clan_tag={correct_tag(clan_tag, '%23')}"
169169
f"&prep_start={str(preparation_start)}")
170170
try:
171-
return ClanWar(data=data["response"], client=self.coc_client)
171+
return ClanWar(data=data["response"], client=self.coc_client, clan_tag=coc.utils.correct_tag(clan_tag))
172172
except (IndexError, KeyError, TypeError, ValueError):
173173
return None
174174

175-
async def war_result_log(self, clan_tag: str) -> Optional[Generator[ClanWar]]:
175+
async def war_result_log(self, clan_tag: str) -> Optional[Generator[ClanWar, None, None]]:
176176
"""Get all stored war results for a clan.
177177
178178
Parameters
@@ -189,9 +189,7 @@ async def war_result_log(self, clan_tag: str) -> Optional[Generator[ClanWar]]:
189189
f"/war_result_log?clan_tag={correct_tag(clan_tag, '%23')}")
190190
try:
191191
responses = data["log"]
192-
193-
generator = (ClanWar(data=response["response"], client=self.coc_client) for response in responses)
194-
return generator
192+
return (ClanWar(data=response["response"], client=self.coc_client, clan_tag=coc.utils.correct_tag(clan_tag)) for response in responses)
195193
except (IndexError, KeyError, TypeError, ValueError):
196194
return None
197195

0 commit comments

Comments
 (0)