Ruff: Add ASYNC checks (#1139)

This commit is contained in:
Christian Clauss
2024-01-10 05:09:42 +01:00
committed by GitHub
parent f3553040bc
commit 3cff5e9898
4 changed files with 26 additions and 50 deletions

View File

@@ -1,6 +1,7 @@
import logging
import os
import aiofiles
import yaml
from database import Base, SessionLocal, engine
from fastapi import Depends, FastAPI, HTTPException, UploadFile
@@ -74,8 +75,8 @@ async def create_app_using_default_config(app_id: str, config: UploadFile = None
yaml.safe_load(contents)
# TODO: validate the config yaml file here
yaml_path = f"configs/{app_id}.yaml"
with open(yaml_path, "w") as file:
file.write(str(contents, "utf-8"))
async with aiofiles.open(yaml_path, mode="w") as file_out:
await file_out.write(str(contents, "utf-8"))
except yaml.YAMLError as exc:
raise HTTPException(detail=f"Error parsing YAML: {exc}", status_code=400)