feat: update to uv (#59)
This commit is contained in:
parent
717d9c88f8
commit
1bce3bde2d
10 changed files with 2309 additions and 3763 deletions
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
|
|
@ -7,7 +7,7 @@ jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Create github release
|
- name: Create github release
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
@ -19,7 +19,7 @@ jobs:
|
||||||
needs: [release]
|
needs: [release]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.EXT_GITHUB }}
|
token: ${{ secrets.EXT_GITHUB }}
|
||||||
repository: lnbits/lnbits-extensions
|
repository: lnbits/lnbits-extensions
|
||||||
|
|
|
||||||
24
Makefile
24
Makefile
|
|
@ -5,27 +5,27 @@ format: prettier black ruff
|
||||||
check: mypy pyright checkblack checkruff checkprettier
|
check: mypy pyright checkblack checkruff checkprettier
|
||||||
|
|
||||||
prettier:
|
prettier:
|
||||||
poetry run ./node_modules/.bin/prettier --write .
|
uv run ./node_modules/.bin/prettier --write .
|
||||||
pyright:
|
pyright:
|
||||||
poetry run ./node_modules/.bin/pyright
|
uv run ./node_modules/.bin/pyright
|
||||||
|
|
||||||
mypy:
|
mypy:
|
||||||
poetry run mypy .
|
uv run mypy .
|
||||||
|
|
||||||
black:
|
black:
|
||||||
poetry run black .
|
uv run black .
|
||||||
|
|
||||||
ruff:
|
ruff:
|
||||||
poetry run ruff check . --fix
|
uv run ruff check . --fix
|
||||||
|
|
||||||
checkruff:
|
checkruff:
|
||||||
poetry run ruff check .
|
uv run ruff check .
|
||||||
|
|
||||||
checkprettier:
|
checkprettier:
|
||||||
poetry run ./node_modules/.bin/prettier --check .
|
uv run ./node_modules/.bin/prettier --check .
|
||||||
|
|
||||||
checkblack:
|
checkblack:
|
||||||
poetry run black --check .
|
uv run black --check .
|
||||||
|
|
||||||
checkeditorconfig:
|
checkeditorconfig:
|
||||||
editorconfig-checker
|
editorconfig-checker
|
||||||
|
|
@ -33,14 +33,14 @@ checkeditorconfig:
|
||||||
test:
|
test:
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
DEBUG=true \
|
DEBUG=true \
|
||||||
poetry run pytest
|
uv run pytest
|
||||||
install-pre-commit-hook:
|
install-pre-commit-hook:
|
||||||
@echo "Installing pre-commit hook to git"
|
@echo "Installing pre-commit hook to git"
|
||||||
@echo "Uninstall the hook with poetry run pre-commit uninstall"
|
@echo "Uninstall the hook with uv run pre-commit uninstall"
|
||||||
poetry run pre-commit install
|
uv run pre-commit install
|
||||||
|
|
||||||
pre-commit:
|
pre-commit:
|
||||||
poetry run pre-commit run --all-files
|
uv run pre-commit run --all-files
|
||||||
|
|
||||||
|
|
||||||
checkbundle:
|
checkbundle:
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,4 @@ withdraw_ext.include_router(withdraw_ext_generic)
|
||||||
withdraw_ext.include_router(withdraw_ext_api)
|
withdraw_ext.include_router(withdraw_ext_api)
|
||||||
withdraw_ext.include_router(withdraw_ext_lnurl)
|
withdraw_ext.include_router(withdraw_ext_lnurl)
|
||||||
|
|
||||||
__all__ = ["withdraw_ext", "withdraw_static_files", "db"]
|
__all__ = ["db", "withdraw_ext", "withdraw_static_files"]
|
||||||
|
|
|
||||||
5
crud.py
5
crud.py
|
|
@ -1,5 +1,4 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
import shortuuid
|
import shortuuid
|
||||||
from lnbits.db import Database
|
from lnbits.db import Database
|
||||||
|
|
@ -39,7 +38,7 @@ async def create_withdraw_link(
|
||||||
return withdraw_link
|
return withdraw_link
|
||||||
|
|
||||||
|
|
||||||
async def get_withdraw_link(link_id: str, num=0) -> Optional[WithdrawLink]:
|
async def get_withdraw_link(link_id: str, num=0) -> WithdrawLink | None:
|
||||||
link = await db.fetchone(
|
link = await db.fetchone(
|
||||||
"SELECT * FROM withdraw.withdraw_link WHERE id = :id",
|
"SELECT * FROM withdraw.withdraw_link WHERE id = :id",
|
||||||
{"id": link_id},
|
{"id": link_id},
|
||||||
|
|
@ -52,7 +51,7 @@ async def get_withdraw_link(link_id: str, num=0) -> Optional[WithdrawLink]:
|
||||||
return link
|
return link
|
||||||
|
|
||||||
|
|
||||||
async def get_withdraw_link_by_hash(unique_hash: str, num=0) -> Optional[WithdrawLink]:
|
async def get_withdraw_link_by_hash(unique_hash: str, num=0) -> WithdrawLink | None:
|
||||||
link = await db.fetchone(
|
link = await db.fetchone(
|
||||||
"SELECT * FROM withdraw.withdraw_link WHERE unique_hash = :hash",
|
"SELECT * FROM withdraw.withdraw_link WHERE unique_hash = :hash",
|
||||||
{"hash": unique_hash},
|
{"hash": unique_hash},
|
||||||
|
|
|
||||||
3673
poetry.lock
generated
3673
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,38 +1,31 @@
|
||||||
[tool.poetry]
|
[project]
|
||||||
name = "lnbits-withdraw"
|
name = "lnbits-withdraw"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
requires-python = ">=3.10,<3.13"
|
||||||
description = "LNbits, free and open-source Lightning wallet and accounts system."
|
description = "LNbits, free and open-source Lightning wallet and accounts system."
|
||||||
authors = ["Alan Bits <alan@lnbits.com>"]
|
authors = [{ name = "Alan Bits", email = "alan@lnbits.com" }]
|
||||||
package-mode = false
|
urls = { Homepage = "https://lnbits.com", Repository = "https://github.com/lnbits/bitcoinswitch_extension" }
|
||||||
|
dependencies = [ "lnbits>1" ]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.uv]
|
||||||
python = "~3.12 | ~3.11 | ~3.10"
|
dev-dependencies = [
|
||||||
lnbits = {version = "*", allow-prereleases = true}
|
"black",
|
||||||
|
"pytest-asyncio",
|
||||||
[tool.poetry.group.dev.dependencies]
|
"pytest",
|
||||||
black = "^24.3.0"
|
"mypy",
|
||||||
pytest-asyncio = "^0.21.0"
|
"pre-commit",
|
||||||
pytest = "^7.3.2"
|
"ruff",
|
||||||
mypy = "^1.5.1"
|
"pytest-md",
|
||||||
pre-commit = "^3.2.2"
|
|
||||||
ruff = "^0.3.2"
|
|
||||||
|
|
||||||
[build-system]
|
|
||||||
requires = ["poetry-core>=1.0.0"]
|
|
||||||
build-backend = "poetry.core.masonry.api"
|
|
||||||
|
|
||||||
[[tool.mypy.overrides]]
|
|
||||||
module = [
|
|
||||||
"lnbits.*",
|
|
||||||
"lnurl.*",
|
|
||||||
"loguru.*",
|
|
||||||
"fastapi.*",
|
|
||||||
"pydantic.*",
|
|
||||||
"pyqrcode.*",
|
|
||||||
"shortuuid.*",
|
|
||||||
"httpx.*",
|
|
||||||
]
|
]
|
||||||
ignore_missing_imports = "True"
|
|
||||||
|
[tool.mypy]
|
||||||
|
plugins = ["pydantic.mypy"]
|
||||||
|
|
||||||
|
[tool.pydantic-mypy]
|
||||||
|
init_forbid_extra = true
|
||||||
|
init_typed = true
|
||||||
|
warn_required_dynamic_aliases = true
|
||||||
|
warn_untyped_fields = true
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
log_cli = false
|
log_cli = false
|
||||||
|
|
|
||||||
40
views.py
40
views.py
|
|
@ -1,9 +1,7 @@
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from io import BytesIO
|
|
||||||
|
|
||||||
import pyqrcode
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Request
|
from fastapi import APIRouter, Depends, HTTPException, Request
|
||||||
from fastapi.responses import HTMLResponse, StreamingResponse
|
from fastapi.responses import HTMLResponse
|
||||||
from lnbits.core.models import User
|
from lnbits.core.models import User
|
||||||
from lnbits.decorators import check_user_exists
|
from lnbits.decorators import check_user_exists
|
||||||
from lnbits.helpers import template_renderer
|
from lnbits.helpers import template_renderer
|
||||||
|
|
@ -53,40 +51,6 @@ async def display(request: Request, link_id):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext_generic.get("/img/{link_id}", response_class=StreamingResponse)
|
|
||||||
async def img(request: Request, link_id):
|
|
||||||
link = await get_withdraw_link(link_id, 0)
|
|
||||||
if not link:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
lnurl = create_lnurl(link, request)
|
|
||||||
except ValueError as exc:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
|
||||||
detail=str(exc),
|
|
||||||
) from exc
|
|
||||||
|
|
||||||
qr = pyqrcode.create(lnurl)
|
|
||||||
stream = BytesIO()
|
|
||||||
qr.svg(stream, scale=3)
|
|
||||||
stream.seek(0)
|
|
||||||
|
|
||||||
async def _generator(stream: BytesIO):
|
|
||||||
yield stream.getvalue()
|
|
||||||
|
|
||||||
return StreamingResponse(
|
|
||||||
_generator(stream),
|
|
||||||
headers={
|
|
||||||
"Content-Type": "image/svg+xml",
|
|
||||||
"Cache-Control": "no-cache, no-store, must-revalidate",
|
|
||||||
"Pragma": "no-cache",
|
|
||||||
"Expires": "0",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext_generic.get("/print/{link_id}", response_class=HTMLResponse)
|
@withdraw_ext_generic.get("/print/{link_id}", response_class=HTMLResponse)
|
||||||
async def print_qr(request: Request, link_id):
|
async def print_qr(request: Request, link_id):
|
||||||
link = await get_withdraw_link(link_id)
|
link = await get_withdraw_link(link_id)
|
||||||
|
|
@ -148,8 +112,6 @@ async def csv(request: Request, link_id):
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
|
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw link does not exist."
|
||||||
)
|
)
|
||||||
# response.status_code = HTTPStatus.NOT_FOUND
|
|
||||||
# return "Withdraw link does not exist."
|
|
||||||
|
|
||||||
if link.uses == 0:
|
if link.uses == 0:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import json
|
import json
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Query, Request
|
from fastapi import APIRouter, Depends, HTTPException, Query, Request
|
||||||
from lnbits.core.crud import get_user
|
from lnbits.core.crud import get_user
|
||||||
|
|
@ -86,7 +85,7 @@ async def api_link_retrieve(
|
||||||
async def api_link_create_or_update(
|
async def api_link_create_or_update(
|
||||||
request: Request,
|
request: Request,
|
||||||
data: CreateWithdrawData,
|
data: CreateWithdrawData,
|
||||||
link_id: Optional[str] = None,
|
link_id: str | None = None,
|
||||||
key_info: WalletTypeInfo = Depends(require_admin_key),
|
key_info: WalletTypeInfo = Depends(require_admin_key),
|
||||||
):
|
):
|
||||||
if data.uses > 250:
|
if data.uses > 250:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import shortuuid
|
import shortuuid
|
||||||
|
|
@ -85,7 +84,7 @@ async def api_lnurl_callback(
|
||||||
unique_hash: str,
|
unique_hash: str,
|
||||||
k1: str,
|
k1: str,
|
||||||
pr: str,
|
pr: str,
|
||||||
id_unique_hash: Optional[str] = None,
|
id_unique_hash: str | None = None,
|
||||||
) -> LnurlErrorResponse | LnurlSuccessResponse:
|
) -> LnurlErrorResponse | LnurlSuccessResponse:
|
||||||
|
|
||||||
link = await get_withdraw_link_by_hash(unique_hash)
|
link = await get_withdraw_link_by_hash(unique_hash)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue