From 0e4cbd40a64c7f5ce8ab85466d4fcbc8d8ed824e Mon Sep 17 00:00:00 2001 From: Davide Casale Date: Fri, 16 Dec 2022 16:03:28 +0100 Subject: [PATCH] Fix other mypy errors and warnings. --- bfxapi/client.py | 4 +++- bfxapi/rest/BfxRestInterface.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bfxapi/client.py b/bfxapi/client.py index dd2fe93..75c3f2a 100644 --- a/bfxapi/client.py +++ b/bfxapi/client.py @@ -1,5 +1,7 @@ from .websocket import BfxWebsocketClient +from typing import Optional + from enum import Enum class Constants(str, Enum): @@ -10,7 +12,7 @@ class Constants(str, Enum): PUB_WSS_HOST = "wss://api-pub.bitfinex.com/ws/2" class Client(object): - def __init__(self, WSS_HOST: str = Constants.WSS_HOST, API_KEY: str = None, API_SECRET: str = None, log_level: str = "WARNING"): + def __init__(self, WSS_HOST: str = Constants.WSS_HOST, API_KEY: Optional[str] = None, API_SECRET: Optional[str] = None, log_level: str = "WARNING"): self.wss = BfxWebsocketClient( host=WSS_HOST, API_KEY=API_KEY, diff --git a/bfxapi/rest/BfxRestInterface.py b/bfxapi/rest/BfxRestInterface.py index 6644247..37f52d3 100644 --- a/bfxapi/rest/BfxRestInterface.py +++ b/bfxapi/rest/BfxRestInterface.py @@ -84,7 +84,7 @@ class _RestPublicEndpoints(_Requests): def t_tickers(self, pairs: Union[List[str], Literal["ALL"]]) -> List[TradingPairTicker]: if isinstance(pairs, str) and pairs == "ALL": - return [ subdata for subdata in self.tickers([ "ALL" ]) if subdata["SYMBOL"].startswith("t") ] + return [ cast(TradingPairTicker, subdata) for subdata in self.tickers([ "ALL" ]) if cast(str, subdata["SYMBOL"]).startswith("t") ] data = self.tickers([ "t" + pair for pair in pairs ]) @@ -92,7 +92,7 @@ class _RestPublicEndpoints(_Requests): def f_tickers(self, currencies: Union[List[str], Literal["ALL"]]) -> List[FundingCurrencyTicker]: if isinstance(currencies, str) and currencies == "ALL": - return [ subdata for subdata in self.tickers([ "ALL" ]) if subdata["SYMBOL"].startswith("f") ] + return [ cast(FundingCurrencyTicker, subdata) for subdata in self.tickers([ "ALL" ]) if cast(str, subdata["SYMBOL"]).startswith("f") ] data = self.tickers([ "f" + currency for currency in currencies ])