mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-10 20:42:32 +02:00
correct typing of the callable
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from typing import Callable
|
from typing import Callable, Union, Dict
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
@@ -13,7 +13,9 @@ fiat_currencies = json.load(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
exchange_rate_providers = {
|
exchange_rate_providers: dict[
|
||||||
|
str, dict[str, Union[str, Callable[[dict, dict], str]]]
|
||||||
|
] = {
|
||||||
"bitfinex": {
|
"bitfinex": {
|
||||||
"name": "Bitfinex",
|
"name": "Bitfinex",
|
||||||
"domain": "bitfinex.com",
|
"domain": "bitfinex.com",
|
||||||
@@ -75,6 +77,6 @@ async def fetch_fiat_exchange_rate(currency: str, provider: str):
|
|||||||
data = r.json()
|
data = r.json()
|
||||||
|
|
||||||
getter = exchange_rate_providers[provider]["getter"]
|
getter = exchange_rate_providers[provider]["getter"]
|
||||||
# TODO: mypy typing does not work out
|
if callable(getter):
|
||||||
rate = float(getter(data, replacements)) # type: ignore
|
rate = float(getter(data, replacements))
|
||||||
return rate
|
return rate
|
||||||
|
Reference in New Issue
Block a user