fix flake8 F401+F403 (module imported but unused + unable to detect undefined names)

This commit is contained in:
Pavol Rusnak 2023-01-21 19:31:42 +00:00
parent 967ce06ca5
commit a49a654137
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
65 changed files with 102 additions and 160 deletions

View File

@ -5,7 +5,6 @@ from decimal import Decimal
from typing import List, NamedTuple, Optional
import bitstring
import embit
import secp256k1
from bech32 import CHARSET, bech32_decode, bech32_encode
from ecdsa import SECP256k1, VerifyingKey

View File

@ -9,7 +9,7 @@ core_app: APIRouter = APIRouter()
core_app_extra: CoreAppExtra = CoreAppExtra()
from .views.admin_api import * # noqa
from .views.api import * # noqa
from .views.generic import * # noqa
from .views.public_api import * # noqa
from .views.admin_api import * # noqa: F401,F403
from .views.api import * # noqa: F401,F403
from .views.generic import * # noqa: F401,F403
from .views.public_api import * # noqa: F401,F403

View File

@ -6,8 +6,8 @@ import time
from sqlite3 import Row
from typing import Callable, Dict, List, Optional
from ecdsa import SECP256k1, SigningKey # type: ignore
from lnurl import encode as lnurl_encode # type: ignore
from ecdsa import SECP256k1, SigningKey
from lnurl import encode as lnurl_encode
from loguru import logger
from pydantic import BaseModel

View File

@ -14,7 +14,6 @@ from lnbits import bolt11
from lnbits.db import Connection
from lnbits.decorators import WalletTypeInfo, require_admin_key
from lnbits.helpers import url_for, urlsafe_short_hash
from lnbits.requestvars import g
from lnbits.settings import (
FAKE_WALLET,
EditableSettings,
@ -22,7 +21,6 @@ from lnbits.settings import (
readonly_variables,
send_admin_user_to_saas,
settings,
transient_variables,
)
from lnbits.wallets.base import PaymentResponse, PaymentStatus

View File

@ -21,6 +21,6 @@ def bleskomat_renderer():
return template_renderer(["lnbits/extensions/bleskomat/templates"])
from .lnurl_api import * # noqa
from .views import * # noqa
from .views_api import * # noqa
from .lnurl_api import * # noqa: F401,F403
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -24,8 +24,8 @@ def boltcards_renderer():
return template_renderer(["lnbits/extensions/boltcards/templates"])
from .lnurl import * # noqa
from .tasks import * # noqa
from .lnurl import * # noqa: F401,F403
from .tasks import * # noqa: F401,F403
def boltcards_start():
@ -33,5 +33,5 @@ def boltcards_start():
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -1,6 +1,3 @@
from lnbits.helpers import urlsafe_short_hash
async def m001_initial(db):
await db.execute(
"""

View File

@ -25,8 +25,8 @@ boltz_static_files = [
]
from .tasks import check_for_pending_swaps, wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def boltz_start():

View File

@ -37,8 +37,8 @@ def cashu_renderer():
from .tasks import startup_cashu_mint, wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def cashu_start():

View File

@ -1,15 +1,7 @@
from typing import List, Optional, Union
from cashu.core.base import MintKeyset
from embit import bip32, bip39, ec, script
from embit.networks import NETWORKS
from loguru import logger
from lnbits.db import Connection, Database
from lnbits.helpers import urlsafe_short_hash
from . import db
from .models import Cashu, Pegs, Promises, Proof
from .models import Cashu
async def create_cashu(

View File

@ -7,7 +7,6 @@ from lnbits.core.models import Payment
from lnbits.tasks import register_invoice_listener
from . import db, ledger
from .crud import get_cashu
async def startup_cashu_mint():

View File

@ -21,5 +21,5 @@ def deezy_renderer():
return template_renderer(["lnbits/extensions/deezy/templates"])
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -1,5 +1,4 @@
from pydantic.main import BaseModel
from sqlalchemy.engine import base # type: ignore
class Token(BaseModel):

View File

@ -1,4 +1,4 @@
from fastapi import FastAPI, Request
from fastapi import Request
from fastapi.params import Depends
from fastapi.templating import Jinja2Templates
from starlette.responses import HTMLResponse

View File

@ -21,5 +21,5 @@ def discordbot_renderer():
return template_renderer(["lnbits/extensions/discordbot/templates"])
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -26,8 +26,8 @@ def events_renderer():
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def events_start():

View File

@ -25,8 +25,8 @@ def example_renderer():
from .tasks import wait_for_paid_invoices
from .views import *
from .views_api import *
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def tpos_start():

View File

@ -22,5 +22,5 @@ def gerty_renderer():
return template_renderer(["lnbits/extensions/gerty/templates"])
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -8,7 +8,7 @@ from loguru import logger
from lnbits.helpers import urlsafe_short_hash
from . import db
from .models import Gerty, Mempool, MempoolEndpoint
from .models import Gerty, MempoolEndpoint
async def create_gerty(wallet_id: str, data: Gerty) -> Gerty:

View File

@ -13,7 +13,7 @@ from lnbits.settings import settings
from lnbits.utils.exchange_rates import satoshis_amount_as_fiat
from .crud import get_mempool_info
from .number_prefixer import *
from .number_prefixer import * # noqa: F403
def get_percent_difference(current, previous, precision=3):

View File

@ -21,4 +21,4 @@ hivemind_static_files = [
}
]
from .views import * # noqa
from .views import * # noqa: F401,F403

View File

@ -32,5 +32,5 @@ def invoices_start():
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -25,8 +25,8 @@ def jukebox_renderer():
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def jukebox_start():

View File

@ -24,10 +24,10 @@ def livestream_renderer():
return template_renderer(["lnbits/extensions/livestream/templates"])
from .lnurl import * # noqa
from .lnurl import * # noqa: F401,F403
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def livestream_start():

View File

@ -2,7 +2,6 @@ import asyncio
from loguru import logger
from lnbits.core import db as core_db
from lnbits.core.models import Payment
from lnbits.core.services import create_invoice, pay_invoice
from lnbits.helpers import get_current_extension_name

View File

@ -24,10 +24,10 @@ def lnaddress_renderer():
return template_renderer(["lnbits/extensions/lnaddress/templates"])
from .lnurl import * # noqa
from .lnurl import * # noqa: F401,F403
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def lnaddress_start():

View File

@ -21,7 +21,7 @@ def lndhub_renderer():
return template_renderer(["lnbits/extensions/lndhub/templates"])
from .decorators import * # noqa
from .utils import * # noqa
from .views import * # noqa
from .views_api import * # noqa
from .decorators import * # noqa: F401,F403
from .utils import * # noqa: F401,F403
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -24,10 +24,10 @@ def lnurldevice_renderer():
return template_renderer(["lnbits/extensions/lnurldevice/templates"])
from .lnurl import * # noqa
from .lnurl import * # noqa: F401,F403
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def lnurldevice_start():

View File

@ -3,7 +3,6 @@ import hmac
from http import HTTPStatus
from io import BytesIO
import shortuuid
from embit import bech32, compact
from fastapi import HTTPException, Query, Request
@ -17,7 +16,6 @@ from .crud import (
create_lnurldevicepayment,
get_lnurldevice,
get_lnurldevicepayment,
get_lnurlpayload,
update_lnurldevicepayment,
)

View File

@ -24,10 +24,10 @@ def lnurlp_renderer():
return template_renderer(["lnbits/extensions/lnurlp/templates"])
from .lnurl import * # noqa
from .lnurl import * # noqa: F401,F403
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def lnurlp_start():

View File

@ -34,8 +34,8 @@ def market_renderer():
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def market_start():

View File

@ -3,14 +3,12 @@ from typing import List, Optional, Union
# from lnbits.db import open_ext_db
from lnbits.db import SQLITE
from lnbits.helpers import urlsafe_short_hash
from lnbits.settings import WALLET
from . import db
from .models import (
ChatMessage,
CreateChatMessage,
CreateMarket,
CreateMarketStalls,
Market,
MarketSettings,
OrderDetail,

View File

@ -10,7 +10,6 @@ from fastapi import (
WebSocketDisconnect,
)
from fastapi.templating import Jinja2Templates
from loguru import logger
from starlette.exceptions import HTTPException
from starlette.responses import HTMLResponse
@ -19,7 +18,6 @@ from lnbits.decorators import check_user_exists
from . import market_ext, market_renderer
from .crud import (
create_chat_message,
create_market_settings,
get_market_market,
get_market_market_stalls,
@ -29,10 +27,8 @@ from .crud import (
get_market_settings,
get_market_stall,
get_market_zone,
get_market_zones,
update_market_product_stock,
)
from .models import CreateChatMessage, SetSettings
from .models import SetSettings
from .notifier import Notifier
templates = Jinja2Templates(directory="templates")

View File

@ -1,6 +1,6 @@
from http import HTTPStatus
from fastapi import Body, Depends, Query, Request
from fastapi import Depends, Query
from loguru import logger
from starlette.exceptions import HTTPException
@ -14,7 +14,7 @@ from lnbits.decorators import (
require_invoice_key,
)
from lnbits.helpers import urlsafe_short_hash
from lnbits.utils.exchange_rates import currencies, get_fiat_rate_satoshis
from lnbits.utils.exchange_rates import currencies
from . import db, market_ext
from .crud import (
@ -45,7 +45,6 @@ from .crud import (
get_market_settings,
get_market_stall,
get_market_stalls,
get_market_stalls_by_ids,
get_market_zone,
get_market_zones,
set_market_order_pubkey,
@ -57,12 +56,7 @@ from .crud import (
)
from .models import (
CreateMarket,
CreateMarketStalls,
Orders,
Products,
SetSettings,
Stalls,
Zones,
createOrder,
createProduct,
createStalls,

View File

@ -12,4 +12,4 @@ def ngrok_renderer():
return template_renderer(["lnbits/extensions/ngrok/templates"])
from .views import *
from .views import * # noqa: F401,F403

View File

@ -32,5 +32,5 @@ def nostrnip5_start():
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -21,6 +21,6 @@ def offlineshop_renderer():
return template_renderer(["lnbits/extensions/offlineshop/templates"])
from .lnurl import * # noqa
from .views import * # noqa
from .views_api import * # noqa
from .lnurl import * # noqa: F401,F403
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -6,13 +6,12 @@ from fastapi import Depends, HTTPException, Query, Request
from starlette.responses import HTMLResponse
from lnbits.core.crud import get_standalone_payment
from lnbits.core.models import Payment, User
from lnbits.core.models import User
from lnbits.core.views.api import api_payment
from lnbits.decorators import check_user_exists
from . import offlineshop_ext, offlineshop_renderer
from .crud import get_item, get_shop
from .models import Item
@offlineshop_ext.get("/", response_class=HTMLResponse)

View File

@ -21,5 +21,5 @@ def paywall_renderer():
return template_renderer(["lnbits/extensions/paywall/templates"])
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -21,6 +21,6 @@ def satsdice_renderer():
return template_renderer(["lnbits/extensions/satsdice/templates"])
from .lnurl import * # noqa
from .views import * # noqa
from .views_api import * # noqa
from .lnurl import * # noqa: F401,F403
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -26,8 +26,8 @@ def satspay_renderer():
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def satspay_start():

View File

@ -25,8 +25,8 @@ def scrub_renderer():
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def scrub_start():

View File

@ -25,8 +25,8 @@ def smtp_renderer():
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def smtp_start():

View File

@ -26,8 +26,8 @@ def splitpayments_renderer():
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def splitpayments_start():

View File

@ -21,5 +21,5 @@ def streamalerts_renderer():
return template_renderer(["lnbits/extensions/streamalerts/templates"])
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -25,8 +25,8 @@ def subdomains_renderer():
from .tasks import wait_for_paid_invoices
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403
def subdomains_start():

View File

@ -21,5 +21,5 @@ def tipjar_renderer():
return template_renderer(["lnbits/extensions/tipjar/templates"])
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -21,5 +21,5 @@ def watchonly_renderer():
return template_renderer(["lnbits/extensions/watchonly/templates"])
from .views import * # noqa
from .views_api import * # noqa
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -22,6 +22,6 @@ def withdraw_renderer():
return template_renderer(["lnbits/extensions/withdraw/templates"])
from .lnurl import * # noqa
from .views import * # noqa
from .views_api import * # noqa
from .lnurl import * # noqa: F401,F403
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403

View File

@ -7,8 +7,6 @@ from starlette import templating
from starlette.datastructures import QueryParams
from starlette.requests import Request
from lnbits.requestvars import g
try:
import jinja2
except ImportError: # pragma: nocover

View File

@ -1,4 +1,4 @@
# flake8: noqa
# flake8: noqa: F401
from .cliche import ClicheWallet

View File

@ -3,7 +3,6 @@ import hashlib
import json
from typing import AsyncGenerator, Optional
import httpx
from loguru import logger
from websocket import create_connection

View File

@ -11,11 +11,6 @@ from loguru import logger
# TODO: https://github.com/lnbits/lnbits/issues/764
# mypy https://github.com/aaugustin/websockets/issues/940
from websockets import connect # type: ignore
from websockets.exceptions import (
ConnectionClosed,
ConnectionClosedError,
ConnectionClosedOK,
)
from lnbits.settings import settings

View File

@ -1,7 +1,6 @@
imports_ok = True
try:
import grpc
from google import protobuf
from grpc import RpcError
except ImportError: # pragma: nocover
imports_ok = False

View File

@ -7,7 +7,6 @@ from typing import AsyncGenerator, Dict, Optional
import httpx
from loguru import logger
from lnbits import bolt11 as lnbits_bolt11
from lnbits.settings import settings
from .base import (

View File

@ -1 +1 @@
from .macaroon import AESCipher, load_macaroon
from .macaroon import AESCipher, load_macaroon # noqa: F401

View File

@ -7,7 +7,6 @@ import httpx
from fastapi.exceptions import HTTPException
from loguru import logger
from lnbits.helpers import url_for
from lnbits.settings import settings
from .base import (

View File

@ -5,8 +5,7 @@ from httpx import AsyncClient
from lnbits.app import create_app
from lnbits.commands import migrate_databases
from lnbits.core.crud import create_account, create_wallet, get_wallet
from lnbits.core.models import BalanceCheck, Payment, User, Wallet
from lnbits.core.crud import create_account, create_wallet
from lnbits.core.views.api import CreateInvoiceData, api_payments_create_invoice
from lnbits.db import Database
from lnbits.settings import settings

View File

@ -1,15 +1,9 @@
import hashlib
import pytest
import pytest_asyncio
from lnbits import bolt11
from lnbits.core.crud import get_wallet
from lnbits.core.views.api import (
CreateInvoiceData,
api_payment,
api_payments_create_invoice,
)
from lnbits.core.views.api import api_payment
from lnbits.settings import get_wallet_class
from ...helpers import get_random_invoice_data, is_regtest

View File

@ -1,7 +1,4 @@
import pytest
import pytest_asyncio
from tests.conftest import client
@pytest.mark.asyncio

View File

@ -1,7 +1,4 @@
import pytest
import pytest_asyncio
from lnbits.core.crud import get_wallet
# check if the client is working

View File

@ -1,7 +1,6 @@
import json
import secrets
import pytest
import pytest_asyncio
from lnbits.core.crud import create_account, create_wallet

View File

@ -1,7 +1,6 @@
import secrets
import pytest
import pytest_asyncio
from lnbits.core.crud import get_wallet
from lnbits.extensions.bleskomat.crud import get_bleskomat_lnurl
@ -10,8 +9,6 @@ from lnbits.extensions.bleskomat.helpers import (
query_to_signing_payload,
)
from lnbits.settings import get_wallet_class, settings
from tests.conftest import client
from tests.extensions.bleskomat.conftest import bleskomat, lnurl
from tests.helpers import credit_wallet, is_regtest
WALLET = get_wallet_class()

View File

@ -1,4 +1,3 @@
import pytest
import pytest_asyncio
from lnbits.core.crud import create_account, create_wallet

View File

@ -1,12 +1,15 @@
import pytest
import pytest_asyncio
from loguru import logger
import pytest_asyncio # noqa: F401
from loguru import logger # noqa: F401
from lnbits.core.crud import get_wallet
from tests.conftest import adminkey_headers_from, client, invoice
from tests.extensions.invoices.conftest import accounting_invoice, invoices_wallet
from tests.helpers import credit_wallet
from tests.mocks import WALLET
from lnbits.core.crud import get_wallet # noqa: F401
from tests.conftest import adminkey_headers_from, client, invoice # noqa: F401
from tests.extensions.invoices.conftest import ( # noqa: F401
accounting_invoice,
invoices_wallet,
)
from tests.helpers import credit_wallet # noqa: F401
from tests.mocks import WALLET # noqa: F401
@pytest.mark.asyncio