🚨 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}")
+4 -5
View File
@@ -30,8 +30,7 @@ async def search(
:param limit: Less or equals 100
:return:
"""
async with ClientSession() as session:
async with session.get(
f"https://create.kahoot.it/rest/kahoots/?query={query}&limit={limit}&cursor={cursor}&searchCluster={search_cluster}&includeExtendedCounters=false&inventoryItemId={inventory_item_id}" # noqa : E501
) as response:
return _Response(**await response.json())
async with ClientSession() as session, session.get(
f"https://create.kahoot.it/rest/kahoots/?query={query}&limit={limit}&cursor={cursor}&searchCluster={search_cluster}&includeExtendedCounters=false&inventoryItemId={inventory_item_id}" # noqa : E501
) as response:
return _Response(**await response.json())