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
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ def copilot_start():
scheduled_tasks.append(task)


__all__ = ["copilot_ext", "copilot_static_files", "copilot_start", "copilot_stop", "db"]
__all__ = ["copilot_ext", "copilot_start", "copilot_static_files", "copilot_stop", "db"]
6 changes: 2 additions & 4 deletions crud.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List, Optional

from lnbits.db import Database
from lnbits.helpers import urlsafe_short_hash

Expand All @@ -20,15 +18,15 @@ async def update_copilot(copilot: Copilot) -> Copilot:
return copilot


async def get_copilot(copilot_id: str) -> Optional[Copilot]:
async def get_copilot(copilot_id: str) -> Copilot | None:
return await db.fetchone(
"SELECT * FROM copilot.newer_copilots WHERE id = :id",
{"id": copilot_id},
Copilot,
)


async def get_copilots(user: str) -> List[Copilot]:
async def get_copilots(user: str) -> list[Copilot]:
return await db.fetchall(
'SELECT * FROM copilot.newer_copilots WHERE "user" = :user',
{"user": user},
Expand Down
24 changes: 11 additions & 13 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from fastapi import Query, Request
from lnurl import encode as lnurl_encode
from pydantic import BaseModel
Expand Down Expand Up @@ -31,27 +29,27 @@ class CreateCopilotData(BaseModel):

class Copilot(BaseModel):
id: str
user: Optional[str]
user: str | None
title: str
lnurl_toggle: int
wallet: Optional[str]
animation1: Optional[str]
animation2: Optional[str]
animation3: Optional[str]
wallet: str | None
animation1: str | None
animation2: str | None
animation3: str | None
animation1threshold: int
animation2threshold: int
animation3threshold: int
animation1webhook: Optional[str]
animation2webhook: Optional[str]
animation3webhook: Optional[str]
lnurl_title: Optional[str]
animation1webhook: str | None
animation2webhook: str | None
animation3webhook: str | None
lnurl_title: str | None
show_message: int
show_ack: int
show_price: Optional[str]
show_price: str | None
amount_made: int
timestamp: int
fullscreen_cam: int
iframe_url: Optional[str]
iframe_url: str | None

def lnurl(self, req: Request) -> str:
url = str(req.url_for("copilot.lnurl_response", cp_id=self.id))
Expand Down
Loading