diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index baa938c66..876c8b8af 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,9 +2,9 @@ name: codeql on: push: - branches: [master, ] + branches: [main, ] pull_request: - branches: [master] + branches: [main] schedule: - cron: '0 12 * * 5' @@ -19,10 +19,10 @@ jobs: - run: git checkout HEAD^2 if: ${{ github.event_name == 'pull_request' }} - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: languages: javascript, python - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index 61f03a2b1..608e2417c 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -2,9 +2,9 @@ name: formatting on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: black: @@ -15,9 +15,3 @@ jobs: - run: python3 -m venv venv - run: ./venv/bin/pip install black - run: make checkblack - prettier: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: npm install - - run: make checkprettier diff --git a/lnbits/app.py b/lnbits/app.py index 2fd18d5bc..748c49a60 100644 --- a/lnbits/app.py +++ b/lnbits/app.py @@ -62,12 +62,12 @@ def create_app(config_object="lnbits.settings") -> FastAPI: ): # Only the browser sends "text/html" request # not fail proof, but everything else get's a JSON response - + if "text/html" in request.headers["accept"]: return template_renderer().TemplateResponse( "error.html", {"request": request, "err": f"{exc.errors()} is not a valid UUID."}, - ) + ) return JSONResponse( status_code=HTTPStatus.NO_CONTENT, diff --git a/lnbits/extensions/withdraw/crud.py b/lnbits/extensions/withdraw/crud.py index 9d55d2451..ab35fafac 100644 --- a/lnbits/extensions/withdraw/crud.py +++ b/lnbits/extensions/withdraw/crud.py @@ -43,7 +43,7 @@ async def create_withdraw_link( urlsafe_short_hash(), int(datetime.now().timestamp()) + data.wait_time, usescsv, - data.webhook_url + data.webhook_url, ), ) link = await get_withdraw_link(link_id, 0) diff --git a/lnbits/extensions/withdraw/lnurl.py b/lnbits/extensions/withdraw/lnurl.py index 0e253d323..ad3fbf5f7 100644 --- a/lnbits/extensions/withdraw/lnurl.py +++ b/lnbits/extensions/withdraw/lnurl.py @@ -114,7 +114,7 @@ async def api_lnurl_callback( await update_withdraw_link(link.id, **changes) payment_request = pr - + payment_hash = await pay_invoice( wallet_id=link.wallet, payment_request=payment_request, diff --git a/lnbits/extensions/withdraw/migrations.py b/lnbits/extensions/withdraw/migrations.py index 5c527e79e..83f3fc242 100644 --- a/lnbits/extensions/withdraw/migrations.py +++ b/lnbits/extensions/withdraw/migrations.py @@ -109,8 +109,9 @@ async def m003_make_hash_check(db): """ ) + async def m004_webhook_url(db): """ Adds webhook_url """ - await db.execute("ALTER TABLE withdraw.withdraw_link ADD COLUMN webhook_url TEXT;") \ No newline at end of file + await db.execute("ALTER TABLE withdraw.withdraw_link ADD COLUMN webhook_url TEXT;") diff --git a/lnbits/helpers.py b/lnbits/helpers.py index c456d468f..71b3dd691 100644 --- a/lnbits/helpers.py +++ b/lnbits/helpers.py @@ -161,7 +161,7 @@ def template_renderer(additional_folders: List = []) -> Jinja2Templates: ["lnbits/templates", "lnbits/core/templates", *additional_folders] ) ) - + if settings.LNBITS_AD_SPACE: t.env.globals["AD_SPACE"] = settings.LNBITS_AD_SPACE t.env.globals["HIDE_API"] = settings.LNBITS_HIDE_API diff --git a/mypy.ini b/mypy.ini index f8b1844b6..735f89e05 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1 +1,7 @@ [mypy] +ignore_missing_imports = True +exclude = lnbits/wallets/lnd_grpc_files/ +exclude = lnbits/extensions/ + +[mypy-lnbits.wallets.lnd_grpc_files.*] +follow_imports = skip diff --git a/tests/mocks.py b/tests/mocks.py index 55f87c427..9a9e31194 100644 --- a/tests/mocks.py +++ b/tests/mocks.py @@ -14,14 +14,6 @@ from lnbits.wallets.fake import FakeWallet from .helpers import get_random_string -# primitive event loop for generate_mock_invoice() -def drive(c): - while True: - try: - c.send(None) - except StopIteration as e: - return e.value - # generates an invoice with FakeWallet async def generate_mock_invoice(**x): @@ -44,6 +36,14 @@ WALLET.create_invoice = generate_mock_invoice # times which makes the db throw an error due to uniqueness contraints # on the checking ID +# # primitive event loop for generate_mock_invoice() +# def drive(c): +# while True: +# try: +# c.send(None) +# except StopIteration as e: +# return e.value + # # finally we await it # invoice = drive(generate_mock_invoice())