From 8cd6c7c9bc2113bd8cbbfe1350b0f3f2eb1708b6 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Mon, 9 Jan 2023 11:54:17 +0200 Subject: [PATCH] refactor: use relative imports for own module --- lnbits/extensions/events/tasks.py | 2 +- lnbits/extensions/events/views_api.py | 2 +- lnbits/extensions/lnaddress/cloudflare.py | 2 +- lnbits/extensions/lnaddress/views_api.py | 2 +- lnbits/extensions/lnticket/views_api.py | 2 +- lnbits/extensions/market/notifier.py | 4 ++-- lnbits/extensions/market/views.py | 6 +++--- lnbits/extensions/satspay/tasks.py | 3 +-- lnbits/extensions/satspay/views.py | 2 +- lnbits/extensions/streamalerts/views_api.py | 6 +----- lnbits/extensions/subdomains/cloudflare.py | 2 +- lnbits/extensions/subdomains/views_api.py | 2 +- 12 files changed, 15 insertions(+), 20 deletions(-) diff --git a/lnbits/extensions/events/tasks.py b/lnbits/extensions/events/tasks.py index 5eae7373d..945e2d281 100644 --- a/lnbits/extensions/events/tasks.py +++ b/lnbits/extensions/events/tasks.py @@ -1,10 +1,10 @@ import asyncio from lnbits.core.models import Payment -from lnbits.extensions.events.models import CreateTicket from lnbits.helpers import get_current_extension_name from lnbits.tasks import register_invoice_listener +from .models import CreateTicket from .views_api import api_ticket_send_ticket diff --git a/lnbits/extensions/events/views_api.py b/lnbits/extensions/events/views_api.py index 4ed3932fb..5ec9b916e 100644 --- a/lnbits/extensions/events/views_api.py +++ b/lnbits/extensions/events/views_api.py @@ -7,7 +7,6 @@ from lnbits.core.crud import get_user from lnbits.core.services import create_invoice from lnbits.core.views.api import api_payment from lnbits.decorators import WalletTypeInfo, get_key_type -from lnbits.extensions.events.models import CreateEvent, CreateTicket from . import events_ext from .crud import ( @@ -24,6 +23,7 @@ from .crud import ( reg_ticket, update_event, ) +from .models import CreateEvent, CreateTicket # Events diff --git a/lnbits/extensions/lnaddress/cloudflare.py b/lnbits/extensions/lnaddress/cloudflare.py index 679cb5153..cf8feaf02 100644 --- a/lnbits/extensions/lnaddress/cloudflare.py +++ b/lnbits/extensions/lnaddress/cloudflare.py @@ -2,7 +2,7 @@ import json import httpx -from lnbits.extensions.lnaddress.models import Domains +from .models import Domains async def cloudflare_create_record(domain: Domains, ip: str): diff --git a/lnbits/extensions/lnaddress/views_api.py b/lnbits/extensions/lnaddress/views_api.py index d9e50e9d4..7d15a55f7 100644 --- a/lnbits/extensions/lnaddress/views_api.py +++ b/lnbits/extensions/lnaddress/views_api.py @@ -6,7 +6,6 @@ from fastapi import Depends, HTTPException, Query, Request from lnbits.core.crud import get_user from lnbits.core.services import check_transaction_status, create_invoice from lnbits.decorators import WalletTypeInfo, get_key_type -from lnbits.extensions.lnaddress.models import CreateAddress, CreateDomain from . import lnaddress_ext from .cloudflare import cloudflare_create_record @@ -23,6 +22,7 @@ from .crud import ( get_domains, update_domain, ) +from .models import CreateAddress, CreateDomain # DOMAINS diff --git a/lnbits/extensions/lnticket/views_api.py b/lnbits/extensions/lnticket/views_api.py index 35d6eaff8..4462688b6 100644 --- a/lnbits/extensions/lnticket/views_api.py +++ b/lnbits/extensions/lnticket/views_api.py @@ -8,7 +8,6 @@ from lnbits.core.crud import get_user from lnbits.core.services import create_invoice from lnbits.core.views.api import api_payment from lnbits.decorators import WalletTypeInfo, get_key_type -from lnbits.extensions.lnticket.models import CreateFormData, CreateTicketData from . import lnticket_ext from .crud import ( @@ -23,6 +22,7 @@ from .crud import ( set_ticket_paid, update_form, ) +from .models import CreateFormData, CreateTicketData # FORMS diff --git a/lnbits/extensions/market/notifier.py b/lnbits/extensions/market/notifier.py index e2bf7c91c..88a1a4a38 100644 --- a/lnbits/extensions/market/notifier.py +++ b/lnbits/extensions/market/notifier.py @@ -10,8 +10,8 @@ from collections import defaultdict from fastapi import WebSocket from loguru import logger -from lnbits.extensions.market.crud import create_chat_message -from lnbits.extensions.market.models import CreateChatMessage +from .crud import create_chat_message +from .models import CreateChatMessage class Notifier: diff --git a/lnbits/extensions/market/views.py b/lnbits/extensions/market/views.py index 23bc57069..27ec7a973 100644 --- a/lnbits/extensions/market/views.py +++ b/lnbits/extensions/market/views.py @@ -17,10 +17,8 @@ from starlette.responses import HTMLResponse from lnbits.core.models import User from lnbits.decorators import check_user_exists # type: ignore -from lnbits.extensions.market import market_ext, market_renderer -from lnbits.extensions.market.models import CreateChatMessage, SetSettings -from lnbits.extensions.market.notifier import Notifier +from . import market_ext, market_renderer from .crud import ( create_chat_message, create_market_settings, @@ -35,6 +33,8 @@ from .crud import ( get_market_zones, update_market_product_stock, ) +from .models import CreateChatMessage, SetSettings +from .notifier import Notifier templates = Jinja2Templates(directory="templates") diff --git a/lnbits/extensions/satspay/tasks.py b/lnbits/extensions/satspay/tasks.py index 992e5eb63..2c636351b 100644 --- a/lnbits/extensions/satspay/tasks.py +++ b/lnbits/extensions/satspay/tasks.py @@ -4,11 +4,10 @@ import json from loguru import logger from lnbits.core.models import Payment -from lnbits.extensions.satspay.crud import check_address_balance, get_charge from lnbits.helpers import get_current_extension_name from lnbits.tasks import register_invoice_listener -from .crud import update_charge +from .crud import check_address_balance, get_charge, update_charge from .helpers import call_webhook diff --git a/lnbits/extensions/satspay/views.py b/lnbits/extensions/satspay/views.py index 15a4403db..175b00bd4 100644 --- a/lnbits/extensions/satspay/views.py +++ b/lnbits/extensions/satspay/views.py @@ -6,10 +6,10 @@ from starlette.responses import HTMLResponse from lnbits.core.models import User from lnbits.decorators import check_user_exists -from lnbits.extensions.satspay.helpers import public_charge from . import satspay_ext, satspay_renderer from .crud import get_charge, get_theme +from .helpers import public_charge templates = Jinja2Templates(directory="templates") diff --git a/lnbits/extensions/streamalerts/views_api.py b/lnbits/extensions/streamalerts/views_api.py index 0134fe825..25033e274 100644 --- a/lnbits/extensions/streamalerts/views_api.py +++ b/lnbits/extensions/streamalerts/views_api.py @@ -8,11 +8,6 @@ from starlette.responses import RedirectResponse from lnbits.core.crud import get_user from lnbits.decorators import WalletTypeInfo, get_key_type from lnbits.extensions.satspay.models import CreateCharge -from lnbits.extensions.streamalerts.models import ( - CreateDonation, - CreateService, - ValidateDonation, -) from lnbits.utils.exchange_rates import btc_price from ..satspay.crud import create_charge, get_charge @@ -33,6 +28,7 @@ from .crud import ( update_donation, update_service, ) +from .models import CreateDonation, CreateService, ValidateDonation @streamalerts_ext.post("/api/v1/services") diff --git a/lnbits/extensions/subdomains/cloudflare.py b/lnbits/extensions/subdomains/cloudflare.py index 679ca8436..5b951b21a 100644 --- a/lnbits/extensions/subdomains/cloudflare.py +++ b/lnbits/extensions/subdomains/cloudflare.py @@ -2,7 +2,7 @@ import json import httpx -from lnbits.extensions.subdomains.models import Domains +from .models import Domains async def cloudflare_create_subdomain( diff --git a/lnbits/extensions/subdomains/views_api.py b/lnbits/extensions/subdomains/views_api.py index 2b20bd1fd..9fbae4f3a 100644 --- a/lnbits/extensions/subdomains/views_api.py +++ b/lnbits/extensions/subdomains/views_api.py @@ -6,7 +6,6 @@ from starlette.exceptions import HTTPException from lnbits.core.crud import get_user from lnbits.core.services import check_transaction_status, create_invoice from lnbits.decorators import WalletTypeInfo, get_key_type -from lnbits.extensions.subdomains.models import CreateDomain, CreateSubdomain from . import subdomains_ext from .cloudflare import cloudflare_create_subdomain, cloudflare_deletesubdomain @@ -22,6 +21,7 @@ from .crud import ( get_subdomains, update_domain, ) +from .models import CreateDomain, CreateSubdomain # domainS