Add formatting and type checks

This commit is contained in:
StasonJatham committed 2026-05-22 17:05:06 +02:00
1 parent c0d82eaf26
commit 24747866bc
38 files changed
+800 -265

No files matched your search

+7 -6
View File
@@ -3,10 +3,11 @@ from __future__ import annotations
from datetime import UTC, datetime
from ..security import hash_lookup_token, hash_secret, new_bearer_secret, verify_secret
from .types import AccountRow
from .base import StoreConnectionMixin
from .types import AccountRow, account_row
class AccountsMixin:
class AccountsMixin(StoreConnectionMixin):
def create_account(self, hostname: str, username: str | None = None, *, accepted: bool = True) -> AccountRow:
now = datetime.now(UTC).isoformat()
update_slug = new_bearer_secret()
@@ -41,7 +42,7 @@ class AccountsMixin:
""",
(limit, offset),
).fetchall()
return [dict(row) for row in rows]
return [account_row(row) for row in rows]
def count_accounts(self) -> int:
with self.connect() as conn:
@@ -60,7 +61,7 @@ class AccountsMixin:
""",
(hostname,),
).fetchone()
return dict(account) if account else None
return account_row(account) if account else None
def get_account_by_slug(self, update_slug: str) -> AccountRow | None:
with self.connect() as conn:
@@ -71,7 +72,7 @@ class AccountsMixin:
""",
(update_slug,),
).fetchone()
return dict(account) if account else None
return account_row(account) if account else None
def get_account_by_management_slug(self, management_slug: str) -> AccountRow | None:
with self.connect() as conn:
@@ -85,7 +86,7 @@ class AccountsMixin:
""",
(hash_lookup_token(management_slug),),
).fetchone()
return dict(account) if account else None
return account_row(account) if account else None
def activate_account(self, hostname: str) -> AccountRow | None:
now = datetime.now(UTC).isoformat()