mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-23 22:47:05 +01:00
correct typing of the callable
This commit is contained in:
parent
85cb8526be
commit
b32404ca5f
1 changed files with 6 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
import json
|
||||
import os
|
||||
from typing import Callable
|
||||
from typing import Callable, Union, Dict
|
||||
|
||||
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": {
|
||||
"name": "Bitfinex",
|
||||
"domain": "bitfinex.com",
|
||||
|
@ -75,6 +77,6 @@ async def fetch_fiat_exchange_rate(currency: str, provider: str):
|
|||
data = r.json()
|
||||
|
||||
getter = exchange_rate_providers[provider]["getter"]
|
||||
# TODO: mypy typing does not work out
|
||||
rate = float(getter(data, replacements)) # type: ignore
|
||||
if callable(getter):
|
||||
rate = float(getter(data, replacements))
|
||||
return rate
|
||||
|
|
Loading…
Add table
Reference in a new issue