🚨 Merged with-statements

This commit is contained in:
Mawoka
2022-04-16 11:54:14 +02:00
parent 69f0aa8846
commit bd23036414
5 changed files with 42 additions and 42 deletions
+9 -8
View File
@@ -10,11 +10,12 @@ class _Response(BaseModel):
async def get(game_id: str) -> _Response | None:
async with ClientSession() as session:
async with session.get(f"https://create.kahoot.it/rest/kahoots/{game_id}/card/?includeKahoot=true") as response:
if response.status == 200:
return _Response(**await response.json())
elif response.status == 404:
return None
else:
raise Exception(f"Unexpected response status: {response.status}")
async with ClientSession() as session, session.get(
f"https://create.kahoot.it/rest/kahoots/{game_id}/card/?includeKahoot=true"
) as response:
if response.status == 200:
return _Response(**await response.json())
elif response.status == 404:
return None
else:
raise Exception(f"Unexpected response status: {response.status}")