removing type: ignore from Query, Depends, Body and import them correctly
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from typing import List
|
||||
|
||||
from fastapi import Request, WebSocket, WebSocketDisconnect
|
||||
from fastapi.params import Depends
|
||||
from fastapi import Depends, Request
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from starlette.responses import HTMLResponse # type: ignore
|
||||
|
||||
@@ -9,15 +8,12 @@ from lnbits.core.models import User
|
||||
from lnbits.decorators import check_user_exists
|
||||
|
||||
from . import copilot_ext, copilot_renderer
|
||||
from .crud import get_copilot
|
||||
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
|
||||
|
||||
@copilot_ext.get("/", response_class=HTMLResponse)
|
||||
async def index(
|
||||
request: Request, user: User = Depends(check_user_exists) # type: ignore
|
||||
):
|
||||
async def index(request: Request, user: User = Depends(check_user_exists)):
|
||||
return copilot_renderer().TemplateResponse(
|
||||
"copilot/index.html", {"request": request, "user": user.dict()}
|
||||
)
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
from http import HTTPStatus
|
||||
|
||||
from fastapi import Request
|
||||
from fastapi.param_functions import Query
|
||||
from fastapi.params import Depends
|
||||
from fastapi.param_functions import Depends, Query
|
||||
from starlette.exceptions import HTTPException
|
||||
|
||||
from lnbits.core.services import websocketUpdater
|
||||
@@ -22,9 +21,7 @@ from .models import CreateCopilotData
|
||||
|
||||
|
||||
@copilot_ext.get("/api/v1/copilot")
|
||||
async def api_copilots_retrieve(
|
||||
req: Request, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
|
||||
):
|
||||
async def api_copilots_retrieve(wallet: WalletTypeInfo = Depends(get_key_type)):
|
||||
wallet_user = wallet.wallet.user
|
||||
copilots = [copilot.dict() for copilot in await get_copilots(wallet_user)]
|
||||
try:
|
||||
@@ -37,7 +34,7 @@ async def api_copilots_retrieve(
|
||||
async def api_copilot_retrieve(
|
||||
req: Request,
|
||||
copilot_id: str = Query(None),
|
||||
wallet: WalletTypeInfo = Depends(get_key_type), # type: ignore
|
||||
wallet: WalletTypeInfo = Depends(get_key_type),
|
||||
):
|
||||
copilot = await get_copilot(copilot_id)
|
||||
if not copilot:
|
||||
@@ -54,7 +51,7 @@ async def api_copilot_retrieve(
|
||||
async def api_copilot_create_or_update(
|
||||
data: CreateCopilotData,
|
||||
copilot_id: str = Query(None),
|
||||
wallet: WalletTypeInfo = Depends(require_admin_key), # type: ignore
|
||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
||||
):
|
||||
data.user = wallet.wallet.user
|
||||
data.wallet = wallet.wallet.id
|
||||
@@ -68,7 +65,7 @@ async def api_copilot_create_or_update(
|
||||
@copilot_ext.delete("/api/v1/copilot/{copilot_id}")
|
||||
async def api_copilot_delete(
|
||||
copilot_id: str = Query(None),
|
||||
wallet: WalletTypeInfo = Depends(require_admin_key), # type: ignore
|
||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
||||
):
|
||||
copilot = await get_copilot(copilot_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user