Skip to content

Commit 7aeba1e

Browse files
talvasconcelosdni
andauthored
Update to use uv (#37)
--------- Co-authored-by: dni ⚡ <[email protected]>
1 parent c729ef1 commit 7aeba1e

File tree

9 files changed

+2297
-2655
lines changed

9 files changed

+2297
-2655
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
needs: [release]
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323
with:
2424
token: ${{ secrets.EXT_GITHUB }}
2525
repository: lnbits/lnbits-extensions

Makefile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,42 @@ format: prettier black ruff
55
check: mypy pyright checkblack checkruff checkprettier
66

77
prettier:
8-
poetry run ./node_modules/.bin/prettier --write .
8+
uv run ./node_modules/.bin/prettier --write .
99
pyright:
10-
poetry run ./node_modules/.bin/pyright
10+
uv run ./node_modules/.bin/pyright
1111

1212
mypy:
13-
poetry run mypy .
13+
uv run mypy .
1414

1515
black:
16-
poetry run black .
16+
uv run black .
1717

1818
ruff:
19-
poetry run ruff check . --fix
19+
uv run ruff check . --fix
2020

2121
checkruff:
22-
poetry run ruff check .
22+
uv run ruff check .
2323

2424
checkprettier:
25-
poetry run ./node_modules/.bin/prettier --check .
25+
uv run ./node_modules/.bin/prettier --check .
2626

2727
checkblack:
28-
poetry run black --check .
28+
uv run black --check .
2929

3030
checkeditorconfig:
3131
editorconfig-checker
3232

3333
test:
3434
PYTHONUNBUFFERED=1 \
3535
DEBUG=true \
36-
poetry run pytest
36+
uv run pytest
3737
install-pre-commit-hook:
3838
@echo "Installing pre-commit hook to git"
39-
@echo "Uninstall the hook with poetry run pre-commit uninstall"
40-
poetry run pre-commit install
39+
@echo "Uninstall the hook with uv run pre-commit uninstall"
40+
uv run pre-commit install
4141

4242
pre-commit:
43-
poetry run pre-commit run --all-files
43+
uv run pre-commit run --all-files
4444

4545

4646
checkbundle:

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ def events_start():
3737
scheduled_tasks.append(task)
3838

3939

40-
__all__ = ["db", "events_ext", "events_static_files", "events_start", "events_stop"]
40+
__all__ = ["db", "events_ext", "events_start", "events_static_files", "events_stop"]

crud.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from datetime import datetime, timedelta, timezone
2-
from typing import Optional, Union
32

43
from lnbits.db import Database
54
from lnbits.helpers import urlsafe_short_hash
@@ -33,15 +32,15 @@ async def update_ticket(ticket: Ticket) -> Ticket:
3332
return ticket
3433

3534

36-
async def get_ticket(payment_hash: str) -> Optional[Ticket]:
35+
async def get_ticket(payment_hash: str) -> Ticket | None:
3736
return await db.fetchone(
3837
"SELECT * FROM events.ticket WHERE id = :id",
3938
{"id": payment_hash},
4039
Ticket,
4140
)
4241

4342

44-
async def get_tickets(wallet_ids: Union[str, list[str]]) -> list[Ticket]:
43+
async def get_tickets(wallet_ids: str | list[str]) -> list[Ticket]:
4544
if isinstance(wallet_ids, str):
4645
wallet_ids = [wallet_ids]
4746
q = ",".join([f"'{wallet_id}'" for wallet_id in wallet_ids])
@@ -84,15 +83,15 @@ async def update_event(event: Event) -> Event:
8483
return event
8584

8685

87-
async def get_event(event_id: str) -> Optional[Event]:
86+
async def get_event(event_id: str) -> Event | None:
8887
return await db.fetchone(
8988
"SELECT * FROM events.events WHERE id = :id",
9089
{"id": event_id},
9190
Event,
9291
)
9392

9493

95-
async def get_events(wallet_ids: Union[str, list[str]]) -> list[Event]:
94+
async def get_events(wallet_ids: str | list[str]) -> list[Event]:
9695
if isinstance(wallet_ids, str):
9796
wallet_ids = [wallet_ids]
9897
q = ",".join([f"'{wallet_id}'" for wallet_id in wallet_ids])

models.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from datetime import datetime
2-
from typing import Optional
32

43
from fastapi import Query
54
from pydantic import BaseModel, EmailStr
@@ -15,7 +14,7 @@ class CreateEvent(BaseModel):
1514
currency: str = "sat"
1615
amount_tickets: int = Query(..., ge=0)
1716
price_per_ticket: float = Query(..., ge=0)
18-
banner: Optional[str] = None
17+
banner: str | None = None
1918

2019

2120
class CreateTicket(BaseModel):
@@ -36,7 +35,7 @@ class Event(BaseModel):
3635
price_per_ticket: float
3736
time: datetime
3837
sold: int = 0
39-
banner: Optional[str] = None
38+
banner: str | None = None
4039

4140

4241
class Ticket(BaseModel):

poetry.lock

Lines changed: 0 additions & 2615 deletions
This file was deleted.

pyproject.toml

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1-
[tool.poetry]
1+
[project]
22
name = "lnbits-events"
33
version = "0.0.0"
4+
requires-python = ">=3.10,<3.13"
45
description = "LNbits, free and open-source Lightning wallet and accounts system."
5-
authors = ["Alan Bits <[email protected]>"]
6+
authors = [{ name = "Alan Bits", email = "[email protected]" }]
7+
urls = { Homepage = "https://lnbits.com", Repository = "https://github.com/lnbits/events" }
68

7-
[tool.poetry.dependencies]
8-
python = "^3.10 | ^3.9"
9-
lnbits = {version = "*", allow-prereleases = true}
9+
dependencies = [ "lnbits>1" ]
1010

11-
[tool.poetry.group.dev.dependencies]
12-
black = "^24.3.0"
13-
pytest-asyncio = "^0.21.0"
14-
pytest = "^7.3.2"
15-
mypy = "^1.5.1"
16-
pre-commit = "^3.2.2"
17-
ruff = "^0.3.2"
18-
19-
[build-system]
20-
requires = ["poetry-core>=1.0.0"]
21-
build-backend = "poetry.core.masonry.api"
11+
[tool.uv]
12+
dev-dependencies = [
13+
"black",
14+
"pytest-asyncio",
15+
"pytest",
16+
"mypy",
17+
"pre-commit",
18+
"ruff",
19+
]
2220

2321
[tool.mypy]
2422
exclude = "(nostr/*)"
23+
plugins = ["pydantic.mypy"]
24+
25+
[tool.pydantic-mypy]
26+
init_forbid_extra = true
27+
init_typed = true
28+
warn_required_dynamic_aliases = true
29+
warn_untyped_fields = true
30+
2531
[[tool.mypy.overrides]]
2632
module = [
2733
"lnbits.*",
@@ -76,6 +82,7 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
7682
# needed for pydantic
7783
[tool.ruff.lint.pep8-naming]
7884
classmethod-decorators = [
85+
"validator",
7986
"root_validator",
8087
]
8188

0 commit comments

Comments
 (0)