From 3bee031b1cccf44347f2fdf3945ad6505cc1a6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Thu, 1 Aug 2024 15:11:59 +0200 Subject: [PATCH] format --- __init__.py | 3 +-- crud.py | 3 +-- models.py | 3 +-- router.py | 7 +++---- tasks.py | 2 +- views.py | 3 +-- views_api.py | 5 ++--- 7 files changed, 10 insertions(+), 16 deletions(-) diff --git a/__init__.py b/__init__.py index f49ed9e..9582e68 100644 --- a/__init__.py +++ b/__init__.py @@ -2,11 +2,10 @@ from typing import List from fastapi import APIRouter -from loguru import logger - from lnbits.db import Database from lnbits.helpers import template_renderer from lnbits.tasks import create_permanent_unique_task +from loguru import logger from .nostr.client.client import NostrClient from .router import NostrRouter diff --git a/crud.py b/crud.py index 851ed34..7962d75 100644 --- a/crud.py +++ b/crud.py @@ -1,6 +1,5 @@ -from typing import List, Optional - import json +from typing import List, Optional from . import db from .models import Config, Relay diff --git a/models.py b/models.py index a794230..9ba5638 100644 --- a/models.py +++ b/models.py @@ -1,9 +1,8 @@ from sqlite3 import Row from typing import List, Optional -from pydantic import BaseModel - from lnbits.helpers import urlsafe_short_hash +from pydantic import BaseModel class RelayStatus(BaseModel): diff --git a/router.py b/router.py index 717fbce..942407a 100644 --- a/router.py +++ b/router.py @@ -3,9 +3,8 @@ from typing import Dict, List from fastapi import WebSocket, WebSocketDisconnect -from loguru import logger - from lnbits.helpers import urlsafe_short_hash +from loguru import logger from . import nostr_client from .nostr.message_pool import EndOfStoredEventsMessage, EventMessage, NoticeMessage @@ -61,7 +60,7 @@ async def _client_to_nostr(self): try: await self._handle_client_to_nostr(json_str) except Exception as e: - logger.debug(f"Failed to handle client message: '{str(e)}'.") + logger.debug(f"Failed to handle client message: '{e!s}'.") async def _nostr_to_client(self): """Sends responses from relays back to the client.""" @@ -70,7 +69,7 @@ async def _nostr_to_client(self): await self._handle_subscriptions() self._handle_notices() except Exception as e: - logger.debug(f"Failed to handle response for client: '{str(e)}'.") + logger.debug(f"Failed to handle response for client: '{e!s}'.") await asyncio.sleep(0.1) async def _handle_subscriptions(self): diff --git a/tasks.py b/tasks.py index 69aa33c..4f51219 100644 --- a/tasks.py +++ b/tasks.py @@ -25,7 +25,7 @@ async def check_relays(): await asyncio.sleep(20) nostr_client.relay_manager.check_and_restart_relays() except Exception as e: - logger.warning(f"Cannot restart relays: '{str(e)}'.") + logger.warning(f"Cannot restart relays: '{e!s}'.") async def subscribe_events(): diff --git a/views.py b/views.py index 57b73a1..9b08559 100644 --- a/views.py +++ b/views.py @@ -1,9 +1,8 @@ from fastapi import Depends, Request from fastapi.templating import Jinja2Templates -from starlette.responses import HTMLResponse - from lnbits.core.models import User from lnbits.decorators import check_admin +from starlette.responses import HTMLResponse from . import nostr_renderer, nostrclient_ext diff --git a/views_api.py b/views_api.py index a7564db..b16dc12 100644 --- a/views_api.py +++ b/views_api.py @@ -3,11 +3,10 @@ from typing import List from fastapi import Depends, WebSocket -from loguru import logger -from starlette.exceptions import HTTPException - from lnbits.decorators import check_admin from lnbits.helpers import decrypt_internal_message, urlsafe_short_hash +from loguru import logger +from starlette.exceptions import HTTPException from . import all_routers, nostr_client, nostrclient_ext from .crud import (