Update to use uv (#37)

---------

Co-authored-by: dni  <office@dnilabs.com>
This commit is contained in:
Tiago Vasconcelos 2025-08-22 15:54:51 +01:00 committed by GitHub
parent c729ef17a6
commit 7aeba1eeb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 2297 additions and 2655 deletions

View file

@ -19,7 +19,7 @@ jobs:
needs: [release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.EXT_GITHUB }}
repository: lnbits/lnbits-extensions

View file

@ -5,27 +5,27 @@ 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
@ -33,14 +33,14 @@ checkeditorconfig:
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:

View file

@ -37,4 +37,4 @@ def events_start():
scheduled_tasks.append(task)
__all__ = ["db", "events_ext", "events_static_files", "events_start", "events_stop"]
__all__ = ["db", "events_ext", "events_start", "events_static_files", "events_stop"]

View file

@ -1,5 +1,4 @@
from datetime import datetime, timedelta, timezone
from typing import Optional, Union
from lnbits.db import Database
from lnbits.helpers import urlsafe_short_hash
@ -33,7 +32,7 @@ async def update_ticket(ticket: Ticket) -> Ticket:
return ticket
async def get_ticket(payment_hash: str) -> Optional[Ticket]:
async def get_ticket(payment_hash: str) -> Ticket | None:
return await db.fetchone(
"SELECT * FROM events.ticket WHERE id = :id",
{"id": payment_hash},
@ -41,7 +40,7 @@ async def get_ticket(payment_hash: str) -> Optional[Ticket]:
)
async def get_tickets(wallet_ids: Union[str, list[str]]) -> list[Ticket]:
async def get_tickets(wallet_ids: str | list[str]) -> list[Ticket]:
if isinstance(wallet_ids, str):
wallet_ids = [wallet_ids]
q = ",".join([f"'{wallet_id}'" for wallet_id in wallet_ids])
@ -84,7 +83,7 @@ async def update_event(event: Event) -> Event:
return event
async def get_event(event_id: str) -> Optional[Event]:
async def get_event(event_id: str) -> Event | None:
return await db.fetchone(
"SELECT * FROM events.events WHERE id = :id",
{"id": event_id},
@ -92,7 +91,7 @@ async def get_event(event_id: str) -> Optional[Event]:
)
async def get_events(wallet_ids: Union[str, list[str]]) -> list[Event]:
async def get_events(wallet_ids: str | list[str]) -> list[Event]:
if isinstance(wallet_ids, str):
wallet_ids = [wallet_ids]
q = ",".join([f"'{wallet_id}'" for wallet_id in wallet_ids])

View file

@ -1,5 +1,4 @@
from datetime import datetime
from typing import Optional
from fastapi import Query
from pydantic import BaseModel, EmailStr
@ -15,7 +14,7 @@ class CreateEvent(BaseModel):
currency: str = "sat"
amount_tickets: int = Query(..., ge=0)
price_per_ticket: float = Query(..., ge=0)
banner: Optional[str] = None
banner: str | None = None
class CreateTicket(BaseModel):
@ -36,7 +35,7 @@ class Event(BaseModel):
price_per_ticket: float
time: datetime
sold: int = 0
banner: Optional[str] = None
banner: str | None = None
class Ticket(BaseModel):

2615
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,27 +1,33 @@
[tool.poetry]
[project]
name = "lnbits-events"
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>"]
authors = [{ name = "Alan Bits", email = "alan@lnbits.com" }]
urls = { Homepage = "https://lnbits.com", Repository = "https://github.com/lnbits/events" }
[tool.poetry.dependencies]
python = "^3.10 | ^3.9"
lnbits = {version = "*", allow-prereleases = true}
dependencies = [ "lnbits>1" ]
[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.3.2"
[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",
]
[tool.mypy]
exclude = "(nostr/*)"
plugins = ["pydantic.mypy"]
[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true
warn_untyped_fields = true
[[tool.mypy.overrides]]
module = [
"lnbits.*",
@ -76,6 +82,7 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# needed for pydantic
[tool.ruff.lint.pep8-naming]
classmethod-decorators = [
"validator",
"root_validator",
]

2253
uv.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,5 @@
from datetime import datetime, timezone
from http import HTTPStatus
from typing import Optional
from fastapi import APIRouter, Depends, Query
from lnbits.core.crud import get_standalone_payment, get_user
@ -56,7 +55,7 @@ async def api_events(
async def api_event_create(
data: CreateEvent,
wallet: WalletTypeInfo = Depends(require_admin_key),
event_id: Optional[str] = None,
event_id: str | None = None,
):
if event_id:
event = await get_event(event_id)