ran pre-commit and fixed issues

This commit is contained in:
Yannic Kilcher
2022-12-13 12:38:59 +01:00
parent ceda5481b9
commit d3d657e636
43 changed files with 213 additions and 154 deletions
+15 -9
View File
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
from typing import Generator
from sqlmodel import Session
from fastapi import Security, HTTPException
from fastapi.security.api_key import APIKeyQuery, APIKeyHeader, APIKey
from app.database import engine
from app.models import ServiceClient
from fastapi import HTTPException, Security
from fastapi.security.api_key import APIKey, APIKeyHeader, APIKeyQuery
from sqlmodel import Session
from starlette.status import HTTP_403_FORBIDDEN
@@ -28,16 +29,21 @@ async def get_api_key(
def api_auth(
api_key: APIKey, db: Session, create: bool = False, read: bool = True, update: bool = False, delete: bool = False
api_key: APIKey,
db: Session,
create: bool = False,
read: bool = True,
update: bool = False,
delete: bool = False,
) -> ServiceClient:
if api_key is not None:
api_client = db.query(ServiceClient).filter(ServiceClient.api_key == api_key).first()
if api_client is not None:
if (
(create == False or api_client.can_append)
and (read == False or api_client.can_read)
and (update == False or api_client.can_write)
and (delete == False or api_client.can_delete)
(create is False or api_client.can_append)
and (read is False or api_client.can_read)
and (update is False or api_client.can_write)
and (delete is False or api_client.can_delete)
):
return api_client
+2 -2
View File
@@ -1,6 +1,6 @@
from fastapi import APIRouter
# -*- coding: utf-8 -*-
from app.api.v1 import labelers, prompts
from fastapi import APIRouter
api_router = APIRouter()
api_router.include_router(labelers.router, prefix="/labelers", tags=["labelers"])
+5 -6
View File
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
from typing import Any, List
from fastapi import APIRouter, Depends, HTTPException
from fastapi.security.api_key import APIKey
from sqlmodel import Session
from starlette.status import HTTP_404_NOT_FOUND, HTTP_400_BAD_REQUEST
from app import crud, schemas
from app.api import deps
from fastapi import APIRouter, Depends, HTTPException
from fastapi.security.api_key import APIKey
from sqlmodel import Session
from starlette.status import HTTP_400_BAD_REQUEST, HTTP_404_NOT_FOUND
router = APIRouter()
+6 -7
View File
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
from typing import Any, List
from fastapi import APIRouter, Depends, HTTPException
from fastapi.security.api_key import APIKey
from sqlmodel import Session
from starlette.status import HTTP_404_NOT_FOUND, HTTP_400_BAD_REQUEST, HTTP_401_UNAUTHORIZED
from app import crud, schemas
from app.api import deps
from fastapi import APIRouter, Depends, HTTPException
from fastapi.security.api_key import APIKey
from sqlmodel import Session
from starlette.status import HTTP_400_BAD_REQUEST, HTTP_401_UNAUTHORIZED, HTTP_404_NOT_FOUND
router = APIRouter()
@@ -50,7 +49,7 @@ def create_prompt(
raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail="Invalid labeler user name")
if not labeler.is_enabled:
raise HTTPException(status_code=HTTP_401_UNAUTHORIZED, detail="Labeler disabled")
item_in.labeler_id = labeler.id
item_in.discord_username = None
item = crud.prompt.create(db=db, obj_in=item_in)