feat: add linters and ci (#28)

* feat: introduce linting and ci
* add locks
* prettier
* black and sorting
* f405 missing imports
* E902
* mypy
* renderer
* circular imports
* check comment
* add exports
* add lnurlerrorhandler only on lnurl routes
* add test case
This commit is contained in:
dni ⚡ 2024-07-11 10:30:28 +02:00 committed by GitHub
commit a44820f61f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 2934 additions and 145 deletions

17
crud.py
View file

@ -2,12 +2,13 @@ from datetime import datetime
from typing import List, Optional, Union
import shortuuid
from lnbits.db import Database
from lnbits.helpers import urlsafe_short_hash
from . import db
from .models import CreateWithdrawData, HashCheck, WithdrawLink
db = Database("ext_withdraw")
async def create_withdraw_link(
data: CreateWithdrawData, wallet_id: str
@ -92,7 +93,11 @@ async def get_withdraw_links(wallet_ids: Union[str, List[str]]) -> List[Withdraw
q = ",".join(["?"] * len(wallet_ids))
rows = await db.fetchall(
f"SELECT * FROM withdraw.withdraw_link WHERE wallet IN ({q}) ORDER BY open_time DESC", (*wallet_ids,)
f"""
SELECT * FROM withdraw.withdraw_link
WHERE wallet IN ({q}) ORDER BY open_time DESC
""",
(*wallet_ids,),
)
return [WithdrawLink(**row) for row in rows]
@ -116,6 +121,7 @@ async def increment_withdraw_link(link: WithdrawLink) -> None:
open_time=link.wait_time + int(datetime.now().timestamp()),
)
async def update_withdraw_link(link_id: str, **kwargs) -> Optional[WithdrawLink]:
if "is_unique" in kwargs:
kwargs["is_unique"] = int(kwargs["is_unique"])
@ -150,8 +156,8 @@ async def create_hash_check(the_hash: str, lnurl_id: str) -> HashCheck:
""",
(the_hash, lnurl_id),
)
hashCheck = await get_hash_check(the_hash, lnurl_id)
return hashCheck
hash_check = await get_hash_check(the_hash, lnurl_id)
return hash_check
async def get_hash_check(the_hash: str, lnurl_id: str) -> HashCheck:
@ -171,5 +177,6 @@ async def get_hash_check(the_hash: str, lnurl_id: str) -> HashCheck:
else:
return HashCheck(lnurl=True, hash=True)
async def delete_hash_check(the_hash: str) -> None:
await db.execute("DELETE FROM withdraw.hash_check WHERE id = ?", (the_hash,))