mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-22 08:14:20 +01:00
Fix all mypy errors and warnings.
This commit is contained in:
@@ -14,7 +14,7 @@ class RestAuthenticatedEndpoints(Middleware):
|
|||||||
def get_user_info(self) -> UserInfo:
|
def get_user_info(self) -> UserInfo:
|
||||||
return serializers.UserInfo.parse(*self._POST(f"auth/r/info/user"))
|
return serializers.UserInfo.parse(*self._POST(f"auth/r/info/user"))
|
||||||
|
|
||||||
def get_login_history(self) -> LoginHistory:
|
def get_login_history(self) -> List[LoginHistory]:
|
||||||
return [ serializers.LoginHistory.parse(*sub_data) for sub_data in self._POST("auth/r/logins/hist") ]
|
return [ serializers.LoginHistory.parse(*sub_data) for sub_data in self._POST("auth/r/logins/hist") ]
|
||||||
|
|
||||||
def get_balance_available_for_orders_or_offers(self, symbol: str, type: str, dir: Optional[int] = None, rate: Optional[str] = None, lev: Optional[str] = None) -> BalanceAvailable:
|
def get_balance_available_for_orders_or_offers(self, symbol: str, type: str, dir: Optional[int] = None, rate: Optional[str] = None, lev: Optional[str] = None) -> BalanceAvailable:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import time, hmac, hashlib, json, requests
|
import time, hmac, hashlib, json, requests
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Optional, Any
|
from typing import TYPE_CHECKING, Optional, Any, cast
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from ..enums import Error
|
from ..enums import Error
|
||||||
@@ -15,7 +15,7 @@ class Middleware(object):
|
|||||||
def __init__(self, host: str, API_KEY: Optional[str] = None, API_SECRET: Optional[str] = None):
|
def __init__(self, host: str, API_KEY: Optional[str] = None, API_SECRET: Optional[str] = None):
|
||||||
self.host, self.API_KEY, self.API_SECRET = host, API_KEY, API_SECRET
|
self.host, self.API_KEY, self.API_SECRET = host, API_KEY, API_SECRET
|
||||||
|
|
||||||
def __build_authentication_headers(self, endpoint: str, data: str):
|
def __build_authentication_headers(self, endpoint: str, data: Optional[str] = None):
|
||||||
assert isinstance(self.API_KEY, str) and isinstance(self.API_SECRET, str), \
|
assert isinstance(self.API_KEY, str) and isinstance(self.API_SECRET, str), \
|
||||||
"API_KEY and API_SECRET must be both str to call __build_authentication_headers"
|
"API_KEY and API_SECRET must be both str to call __build_authentication_headers"
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ class Middleware(object):
|
|||||||
|
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
|
||||||
if len(data) and data[0] == "error":
|
if isinstance(data, list) and len(data) and data[0] == "error":
|
||||||
if data[1] == Error.ERR_PARAMS:
|
if data[1] == Error.ERR_PARAMS:
|
||||||
raise RequestParametersError(f"The request was rejected with the following parameter error: <{data[2]}>")
|
raise RequestParametersError(f"The request was rejected with the following parameter error: <{data[2]}>")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user