From aefea9b8018101354d016feb13b139e590342921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Thu, 24 Nov 2022 14:53:11 +0100 Subject: [PATCH] mypy and formatting --- lnbits/extensions/admin/crud.py | 6 +++--- lnbits/extensions/admin/views.py | 2 +- lnbits/extensions/admin/views_api.py | 6 ++++-- lnbits/server.py | 6 +++++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lnbits/extensions/admin/crud.py b/lnbits/extensions/admin/crud.py index 2ce916127..7f9779b0d 100644 --- a/lnbits/extensions/admin/crud.py +++ b/lnbits/extensions/admin/crud.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Optional from lnbits.core.crud import create_payment from lnbits.helpers import urlsafe_short_hash @@ -9,7 +9,7 @@ from . import db from .models import AdminSettings, UpdateSettings -async def update_wallet_balance(wallet_id: str, amount: int) -> str: +async def update_wallet_balance(wallet_id: str, amount: int) -> None: temp_id = f"temp_{urlsafe_short_hash()}" internal_id = f"internal_{urlsafe_short_hash()}" @@ -36,7 +36,7 @@ async def get_settings() -> AdminSettings: return settings -async def update_settings(data: UpdateSettings) -> Settings: +async def update_settings(data: UpdateSettings) -> Optional[Settings]: fields = [] for key, value in data.dict(exclude_none=True).items(): if not key in read_only_variables: diff --git a/lnbits/extensions/admin/views.py b/lnbits/extensions/admin/views.py index aa9330179..b1d680262 100644 --- a/lnbits/extensions/admin/views.py +++ b/lnbits/extensions/admin/views.py @@ -17,7 +17,7 @@ templates = Jinja2Templates(directory="templates") @admin_ext.get("/", response_class=HTMLResponse) -async def index(request: Request, user: User = Depends(check_admin)): +async def index(request: Request, user: User = Depends(check_admin)): # type: ignore WALLET = get_wallet_class() error, balance = await WALLET.status() diff --git a/lnbits/extensions/admin/views_api.py b/lnbits/extensions/admin/views_api.py index 57d62ed49..eb1eff806 100644 --- a/lnbits/extensions/admin/views_api.py +++ b/lnbits/extensions/admin/views_api.py @@ -1,6 +1,7 @@ from http import HTTPStatus -from fastapi import Body, Depends, Query +from fastapi import Body +from fastapi.params import Depends from starlette.exceptions import HTTPException from lnbits.core.crud import get_wallet @@ -51,7 +52,8 @@ async def api_update_settings( data: UpdateSettings = Body(...), ): settings = await update_settings(data) - return {"status": "Success", "settings": settings.dict()} + if settings: + return {"status": "Success", "settings": settings.dict()} @admin_ext.delete( diff --git a/lnbits/server.py b/lnbits/server.py index 3d2099615..70b158682 100644 --- a/lnbits/server.py +++ b/lnbits/server.py @@ -19,7 +19,11 @@ from lnbits.settings import set_cli_settings, settings ) @click.option("--port", default=settings.port, help="Port to listen on") @click.option("--host", default=settings.host, help="Host to run LNBits on") -@click.option("--forwarded-allow-ips", default=settings.forwarded_allow_ips, help="Allowed proxy servers") +@click.option( + "--forwarded-allow-ips", + default=settings.forwarded_allow_ips, + help="Allowed proxy servers", +) @click.option("--ssl-keyfile", default=None, help="Path to SSL keyfile") @click.option("--ssl-certfile", default=None, help="Path to SSL certificate") @click.pass_context