Update to use uv (#37)
---------
Co-authored-by: dni ⚡ <office@dnilabs.com>
This commit is contained in:
parent
c729ef17a6
commit
7aeba1eeb4
9 changed files with 2297 additions and 2655 deletions
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -37,4 +37,4 @@ def events_start():
|
||||||
scheduled_tasks.append(task)
|
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"]
|
||||||
|
|
|
||||||
9
crud.py
9
crud.py
|
|
@ -1,5 +1,4 @@
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from typing import Optional, Union
|
|
||||||
|
|
||||||
from lnbits.db import Database
|
from lnbits.db import Database
|
||||||
from lnbits.helpers import urlsafe_short_hash
|
from lnbits.helpers import urlsafe_short_hash
|
||||||
|
|
@ -33,7 +32,7 @@ async def update_ticket(ticket: Ticket) -> Ticket:
|
||||||
return 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(
|
return await db.fetchone(
|
||||||
"SELECT * FROM events.ticket WHERE id = :id",
|
"SELECT * FROM events.ticket WHERE id = :id",
|
||||||
{"id": payment_hash},
|
{"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):
|
if isinstance(wallet_ids, str):
|
||||||
wallet_ids = [wallet_ids]
|
wallet_ids = [wallet_ids]
|
||||||
q = ",".join([f"'{wallet_id}'" for wallet_id in 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
|
return event
|
||||||
|
|
||||||
|
|
||||||
async def get_event(event_id: str) -> Optional[Event]:
|
async def get_event(event_id: str) -> Event | None:
|
||||||
return await db.fetchone(
|
return await db.fetchone(
|
||||||
"SELECT * FROM events.events WHERE id = :id",
|
"SELECT * FROM events.events WHERE id = :id",
|
||||||
{"id": event_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):
|
if isinstance(wallet_ids, str):
|
||||||
wallet_ids = [wallet_ids]
|
wallet_ids = [wallet_ids]
|
||||||
q = ",".join([f"'{wallet_id}'" for wallet_id in wallet_ids])
|
q = ",".join([f"'{wallet_id}'" for wallet_id in wallet_ids])
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from fastapi import Query
|
from fastapi import Query
|
||||||
from pydantic import BaseModel, EmailStr
|
from pydantic import BaseModel, EmailStr
|
||||||
|
|
@ -15,7 +14,7 @@ class CreateEvent(BaseModel):
|
||||||
currency: str = "sat"
|
currency: str = "sat"
|
||||||
amount_tickets: int = Query(..., ge=0)
|
amount_tickets: int = Query(..., ge=0)
|
||||||
price_per_ticket: float = Query(..., ge=0)
|
price_per_ticket: float = Query(..., ge=0)
|
||||||
banner: Optional[str] = None
|
banner: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class CreateTicket(BaseModel):
|
class CreateTicket(BaseModel):
|
||||||
|
|
@ -36,7 +35,7 @@ class Event(BaseModel):
|
||||||
price_per_ticket: float
|
price_per_ticket: float
|
||||||
time: datetime
|
time: datetime
|
||||||
sold: int = 0
|
sold: int = 0
|
||||||
banner: Optional[str] = None
|
banner: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class Ticket(BaseModel):
|
class Ticket(BaseModel):
|
||||||
|
|
|
||||||
2615
poetry.lock
generated
2615
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,27 +1,33 @@
|
||||||
[tool.poetry]
|
[project]
|
||||||
name = "lnbits-events"
|
name = "lnbits-events"
|
||||||
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" }]
|
||||||
|
urls = { Homepage = "https://lnbits.com", Repository = "https://github.com/lnbits/events" }
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
dependencies = [ "lnbits>1" ]
|
||||||
python = "^3.10 | ^3.9"
|
|
||||||
lnbits = {version = "*", allow-prereleases = true}
|
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.uv]
|
||||||
black = "^24.3.0"
|
dev-dependencies = [
|
||||||
pytest-asyncio = "^0.21.0"
|
"black",
|
||||||
pytest = "^7.3.2"
|
"pytest-asyncio",
|
||||||
mypy = "^1.5.1"
|
"pytest",
|
||||||
pre-commit = "^3.2.2"
|
"mypy",
|
||||||
ruff = "^0.3.2"
|
"pre-commit",
|
||||||
|
"ruff",
|
||||||
[build-system]
|
]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
|
||||||
build-backend = "poetry.core.masonry.api"
|
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
exclude = "(nostr/*)"
|
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]]
|
[[tool.mypy.overrides]]
|
||||||
module = [
|
module = [
|
||||||
"lnbits.*",
|
"lnbits.*",
|
||||||
|
|
@ -76,6 +82,7 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
||||||
# needed for pydantic
|
# needed for pydantic
|
||||||
[tool.ruff.lint.pep8-naming]
|
[tool.ruff.lint.pep8-naming]
|
||||||
classmethod-decorators = [
|
classmethod-decorators = [
|
||||||
|
"validator",
|
||||||
"root_validator",
|
"root_validator",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, Query
|
from fastapi import APIRouter, Depends, Query
|
||||||
from lnbits.core.crud import get_standalone_payment, get_user
|
from lnbits.core.crud import get_standalone_payment, get_user
|
||||||
|
|
@ -56,7 +55,7 @@ async def api_events(
|
||||||
async def api_event_create(
|
async def api_event_create(
|
||||||
data: CreateEvent,
|
data: CreateEvent,
|
||||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
wallet: WalletTypeInfo = Depends(require_admin_key),
|
||||||
event_id: Optional[str] = None,
|
event_id: str | None = None,
|
||||||
):
|
):
|
||||||
if event_id:
|
if event_id:
|
||||||
event = await get_event(event_id)
|
event = await get_event(event_id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue