Merge pull request #335 from mawoka-myblock/pre-commit-ci-update-config

[pre-commit.ci] pre-commit autoupdate
This commit is contained in:
Marlon
2024-01-29 22:26:10 +01:00
committed by GitHub
6 changed files with 33 additions and 23 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ repos:
# - id: check-added-large-files
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
+8 -4
View File
@@ -70,9 +70,10 @@ async def generate_spreadsheet(quiz_results: dict, quiz: Quiz, player_fields: di
worksheet.write(i + 1, 1, question["time"])
try:
async with ClientSession() as session, session.get(
f"{settings.root_address}/api/v1/storage/download/{question['image']}"
) as response:
async with (
ClientSession() as session,
session.get(f"{settings.root_address}/api/v1/storage/download/{question['image']}") as response,
):
if "image" in response.headers.get("Content-Type"):
img_data = BytesIO(await response.read())
worksheet.insert_image(i + 1, 2, question["image"], {"image_data": img_data})
@@ -226,13 +227,16 @@ async def telemetry_ping():
except ormar.exceptions.NoMatch:
instance_data = InstanceData()
await instance_data.save()
async with ClientSession() as session, session.post(
async with (
ClientSession() as session,
session.post(
f"https://cit.mawoka.eu.org/public/{instance_data.instance_id}",
json={
"public_quizzes": await Quiz.objects.filter(public=True).count(),
"private_quizzes": await Quiz.objects.filter(public=False).count(),
"users": await User.objects.count(),
},
),
):
return
+4 -3
View File
@@ -125,9 +125,10 @@ class NotFoundError(Exception):
async def get_images(api_key: str, params: GetImagesParams) -> GetImagesResponse:
async with ClientSession() as session, session.get(
"https://pixabay.com/api/", params={"key": api_key, **params.dict()}
) as resp:
async with (
ClientSession() as session,
session.get("https://pixabay.com/api/", params={"key": api_key, **params.dict()}) as resp,
):
if resp.status == 200:
return GetImagesResponse.parse_obj(await resp.json())
else:
+4 -3
View File
@@ -15,9 +15,10 @@ class _Response(BaseModel):
async def get(game_id: str) -> _Response | int:
async with ClientSession() as session, session.get(
f"https://create.kahoot.it/rest/kahoots/{game_id}/card/?includeKahoot=true"
) as response:
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())
else:
+5 -2
View File
@@ -35,7 +35,10 @@ async def search(
:param limit: Less or equals 100
:return:
"""
async with ClientSession() as session, session.get(
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:
) as response,
):
return _Response(**await response.json())
+4 -3
View File
@@ -62,9 +62,10 @@ async def export_quiz(quiz_id: uuid.UUID, user: User = Depends(get_current_user)
for image_key in image_urls:
bin_data = bin_data + image_delimiter + str(image_key).encode("utf-8") + image_index_delimiter
image_data = None
async with ClientSession() as session, session.get(
f"{settings.root_address}/api/v1/storage/download/{image_urls[image_key]}"
) as resp:
async with (
ClientSession() as session,
session.get(f"{settings.root_address}/api/v1/storage/download/{image_urls[image_key]}") as resp,
):
image_data = await resp.read()
bin_data = bin_data + image_data