From 2167aa398fdc08ce4fd2a9778933ba09a53e9de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Tue, 23 Jul 2024 14:03:27 +0200 Subject: [PATCH] fix: annotations for models.py (#2595) --- lnbits/core/models.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lnbits/core/models.py b/lnbits/core/models.py index 83214c745..aa6fc1a36 100644 --- a/lnbits/core/models.py +++ b/lnbits/core/models.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import datetime import hashlib import hmac @@ -6,7 +8,7 @@ import time from dataclasses import dataclass from enum import Enum from sqlite3 import Row -from typing import Callable, Dict, List, Optional +from typing import Callable, Optional from ecdsa import SECP256k1, SigningKey from fastapi import Query @@ -62,7 +64,7 @@ class Wallet(BaseWallet): linking_key, curve=SECP256k1, hashfunc=hashlib.sha256 ) - async def get_payment(self, payment_hash: str) -> Optional["Payment"]: + async def get_payment(self, payment_hash: str) -> Optional[Payment]: from .crud import get_standalone_payment return await get_standalone_payment(payment_hash) @@ -132,8 +134,8 @@ class User(BaseModel): id: str email: Optional[str] = None username: Optional[str] = None - extensions: List[str] = [] - wallets: List[Wallet] = [] + extensions: list[str] = [] + wallets: list[Wallet] = [] admin: bool = False super_user: bool = False has_password: bool = False @@ -142,10 +144,10 @@ class User(BaseModel): updated_at: Optional[int] = None @property - def wallet_ids(self) -> List[str]: + def wallet_ids(self) -> list[str]: return [wallet.id for wallet in self.wallets] - def get_wallet(self, wallet_id: str) -> Optional["Wallet"]: + def get_wallet(self, wallet_id: str) -> Optional[Wallet]: w = [wallet for wallet in self.wallets if wallet.id == wallet_id] return w[0] if w else None @@ -208,7 +210,7 @@ class Payment(FromRowModel): preimage: str payment_hash: str expiry: Optional[float] - extra: Dict = {} + extra: dict = {} wallet_id: str webhook: Optional[str] webhook_status: Optional[int] @@ -349,7 +351,7 @@ class PaymentFilters(FilterModel): preimage: str payment_hash: str expiry: Optional[datetime.datetime] - extra: Dict = {} + extra: dict = {} wallet_id: str webhook: Optional[str] webhook_status: Optional[int]