Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,42 @@ format: prettier black ruff
check: mypy pyright checkblack checkruff checkprettier

prettier:
poetry run ./node_modules/.bin/prettier --write .
uv run ./node_modules/.bin/prettier --write .
pyright:
poetry run ./node_modules/.bin/pyright
uv run ./node_modules/.bin/pyright

mypy:
poetry run mypy .
uv run mypy .

black:
poetry run black .
uv run black .

ruff:
poetry run ruff check . --fix
uv run ruff check . --fix

checkruff:
poetry run ruff check .
uv run ruff check .

checkprettier:
poetry run ./node_modules/.bin/prettier --check .
uv run ./node_modules/.bin/prettier --check .

checkblack:
poetry run black --check .
uv run black --check .

checkeditorconfig:
editorconfig-checker

test:
PYTHONUNBUFFERED=1 \
DEBUG=true \
poetry run pytest
uv run pytest
install-pre-commit-hook:
@echo "Installing pre-commit hook to git"
@echo "Uninstall the hook with poetry run pre-commit uninstall"
poetry run pre-commit install
@echo "Uninstall the hook with uv run pre-commit uninstall"
uv run pre-commit install

pre-commit:
poetry run pre-commit run --all-files
uv run pre-commit run --all-files


checkbundle:
Expand Down
4 changes: 2 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def boltcards_start():


__all__ = [
"db",
"boltcards_ext",
"boltcards_static_files",
"boltcards_start",
"boltcards_static_files",
"boltcards_stop",
"db",
]
15 changes: 7 additions & 8 deletions crud.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import secrets
from datetime import datetime
from typing import Optional

from lnbits.db import Database
from lnbits.helpers import urlsafe_short_hash
Expand Down Expand Up @@ -72,31 +71,31 @@ async def get_cards(wallet_ids: list[str]) -> list[Card]:
)


async def get_card(card_id: str) -> Optional[Card]:
async def get_card(card_id: str) -> Card | None:
return await db.fetchone(
"SELECT * FROM boltcards.cards WHERE id = :id",
{"id": card_id},
Card,
)


async def get_card_by_uid(card_uid: str) -> Optional[Card]:
async def get_card_by_uid(card_uid: str) -> Card | None:
return await db.fetchone(
"SELECT * FROM boltcards.cards WHERE uid = :uid",
{"uid": card_uid.upper()},
Card,
)


async def get_card_by_external_id(external_id: str) -> Optional[Card]:
async def get_card_by_external_id(external_id: str) -> Card | None:
return await db.fetchone(
"SELECT * FROM boltcards.cards WHERE external_id = :ext_id",
{"ext_id": external_id.lower()},
Card,
)


async def get_card_by_otp(otp: str) -> Optional[Card]:
async def get_card_by_otp(otp: str) -> Card | None:
return await db.fetchone(
"SELECT * FROM boltcards.cards WHERE otp = :otp",
{"otp": otp},
Expand Down Expand Up @@ -126,7 +125,7 @@ async def update_card_counter(counter: int, card_id: str):
)


async def enable_disable_card(enable: bool, card_id: str) -> Optional[Card]:
async def enable_disable_card(enable: bool, card_id: str) -> Card | None:
await db.execute(
"UPDATE boltcards.cards SET enable = :enable WHERE id = :id",
{"enable": enable, "id": card_id},
Expand All @@ -141,7 +140,7 @@ async def update_card_otp(otp: str, card_id: str):
)


async def get_hit(hit_id: str) -> Optional[Hit]:
async def get_hit(hit_id: str) -> Hit | None:
return await db.fetchone(
"SELECT * FROM boltcards.hits WHERE id = :id",
{"id": hit_id},
Expand Down Expand Up @@ -236,7 +235,7 @@ async def create_refund(hit_id, refund_amount) -> Refund:
return refund


async def get_refund(refund_id: str) -> Optional[Refund]:
async def get_refund(refund_id: str) -> Refund | None:
return await db.fetchone(
"SELECT * FROM boltcards.refunds WHERE id = :id",
{"id": refund_id},
Expand Down
4 changes: 2 additions & 2 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ class Refund(BaseModel):


class UIDPost(BaseModel):
UID: str = Field(None, description="The UID of the card.")
LNURLW: str = Field(None, description="The LNURLW of the card.")
UID: str = Field(description="The UID of the card.")
LNURLW: str = Field(description="The LNURLW of the card.")
3,609 changes: 0 additions & 3,609 deletions poetry.lock

This file was deleted.

54 changes: 24 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
[tool.poetry]
[project]
name = "lnbits-boltcards"
version = "0.0.0"
requires-python = ">=3.10,<3.13"
description = "LNbits, free and open-source Lightning wallet and accounts system."
authors = ["Alan Bits <alan@lnbits.com>"]
package-mode = false
authors = [{ name = "Alan Bits", email = "alan@lnbits.com" }]
urls = { Homepage = "https://lnbits.com", Repository = "https://github.com/lnbits/bitcoinswitch_extension" }
dependencies = [ "lnbits>1" ]

[tool.poetry.dependencies]
python = "~3.12 | ~3.11 | ~3.10"
lnbits = {version = "*", allow-prereleases = true}

[tool.poetry.group.dev.dependencies]
black = "^24.3.0"
pytest-asyncio = "^0.21.0"
pytest = "^7.3.2"
mypy = "^1.5.1"
pre-commit = "^3.2.2"
ruff = "^0.6.3"
[tool.poetry]
package-mode = false

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.uv]
dev-dependencies = [
"black",
"pytest-asyncio",
"pytest",
"mypy",
"pre-commit",
"ruff",
"pytest-md",
]

[tool.mypy]
exclude = "(nostr/*)"
[[tool.mypy.overrides]]
module = [
"lnbits.*",
"lnurl.*",
"loguru.*",
"fastapi.*",
"pydantic.*",
"pyqrcode.*",
"shortuuid.*",
"httpx.*",
]
ignore_missing_imports = "True"
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]
log_cli = false
Expand Down
Loading