mypy and formatting

This commit is contained in:
dni ⚡ 2022-11-24 14:53:11 +01:00
parent a92bb03664
commit aefea9b801
4 changed files with 13 additions and 7 deletions

View file

@ -1,4 +1,4 @@
from typing import List from typing import List, Optional
from lnbits.core.crud import create_payment from lnbits.core.crud import create_payment
from lnbits.helpers import urlsafe_short_hash from lnbits.helpers import urlsafe_short_hash
@ -9,7 +9,7 @@ from . import db
from .models import AdminSettings, UpdateSettings 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()}" temp_id = f"temp_{urlsafe_short_hash()}"
internal_id = f"internal_{urlsafe_short_hash()}" internal_id = f"internal_{urlsafe_short_hash()}"
@ -36,7 +36,7 @@ async def get_settings() -> AdminSettings:
return settings return settings
async def update_settings(data: UpdateSettings) -> Settings: async def update_settings(data: UpdateSettings) -> Optional[Settings]:
fields = [] fields = []
for key, value in data.dict(exclude_none=True).items(): for key, value in data.dict(exclude_none=True).items():
if not key in read_only_variables: if not key in read_only_variables:

View file

@ -17,7 +17,7 @@ templates = Jinja2Templates(directory="templates")
@admin_ext.get("/", response_class=HTMLResponse) @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() WALLET = get_wallet_class()
error, balance = await WALLET.status() error, balance = await WALLET.status()

View file

@ -1,6 +1,7 @@
from http import HTTPStatus 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 starlette.exceptions import HTTPException
from lnbits.core.crud import get_wallet from lnbits.core.crud import get_wallet
@ -51,6 +52,7 @@ async def api_update_settings(
data: UpdateSettings = Body(...), data: UpdateSettings = Body(...),
): ):
settings = await update_settings(data) settings = await update_settings(data)
if settings:
return {"status": "Success", "settings": settings.dict()} return {"status": "Success", "settings": settings.dict()}

View file

@ -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("--port", default=settings.port, help="Port to listen on")
@click.option("--host", default=settings.host, help="Host to run LNBits 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-keyfile", default=None, help="Path to SSL keyfile")
@click.option("--ssl-certfile", default=None, help="Path to SSL certificate") @click.option("--ssl-certfile", default=None, help="Path to SSL certificate")
@click.pass_context @click.pass_context