mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 06:44:22 +01:00
Fix all flake8 errors in all python files (+ edit configuration files).
This commit is contained in:
6
.flake8
Normal file
6
.flake8
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[flake8]
|
||||||
|
max-line-length = 88
|
||||||
|
extend-select = B950
|
||||||
|
extend-ignore = E203,E501,E701
|
||||||
|
|
||||||
|
per-file-ignores = */__init__.py:F401
|
||||||
@@ -13,4 +13,4 @@ def _object_hook(data: Dict[str, Any]) -> Any:
|
|||||||
|
|
||||||
class JSONDecoder(json.JSONDecoder):
|
class JSONDecoder(json.JSONDecoder):
|
||||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||||
super().__init__(object_hook=_object_hook, *args, **kwargs)
|
super().__init__(*args, **kwargs, object_hook=_object_hook)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import sys
|
import sys
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
from logging import FileHandler, Formatter, Logger, LogRecord, StreamHandler
|
||||||
from logging import *
|
|
||||||
from typing import TYPE_CHECKING, Literal, Optional
|
from typing import TYPE_CHECKING, Literal, Optional
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|||||||
@@ -178,8 +178,10 @@ class RestMerchantEndpoints(Middleware):
|
|||||||
def get_merchant_settings(self, key: str) -> Any:
|
def get_merchant_settings(self, key: str) -> Any:
|
||||||
return self._post("auth/r/ext/pay/settings/get", body={"key": key})
|
return self._post("auth/r/ext/pay/settings/get", body={"key": key})
|
||||||
|
|
||||||
def list_merchant_settings(self, keys: List[str] = []) -> Dict[str, Any]:
|
def list_merchant_settings(
|
||||||
return self._post("auth/r/ext/pay/settings/list", body={"keys": keys})
|
self, keys: Optional[List[str]] = None
|
||||||
|
) -> Dict[str, Any]:
|
||||||
|
return self._post("auth/r/ext/pay/settings/list", body={"keys": keys or []})
|
||||||
|
|
||||||
def get_deposits(
|
def get_deposits(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ def partial(cls):
|
|||||||
|
|
||||||
if len(kwargs) != 0:
|
if len(kwargs) != 0:
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f"{cls.__name__}.__init__() got an unexpected keyword argument '{list(kwargs.keys())[0]}'"
|
f"{cls.__name__}.__init__() got an unexpected "
|
||||||
|
"keyword argument '{list(kwargs.keys())[0]}'"
|
||||||
)
|
)
|
||||||
|
|
||||||
cls.__init__ = __init__
|
cls.__init__ = __init__
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
from . import dataclasses
|
from . import dataclasses
|
||||||
|
from .labeler import ( # noqa: F401
|
||||||
from .labeler import (
|
|
||||||
_Serializer,
|
_Serializer,
|
||||||
generate_labeler_serializer,
|
generate_labeler_serializer,
|
||||||
generate_recursive_serializer,
|
generate_recursive_serializer,
|
||||||
)
|
)
|
||||||
|
from .notification import _Notification # noqa: F401
|
||||||
from .notification import _Notification
|
|
||||||
|
|
||||||
__serializers__ = [
|
__serializers__ = [
|
||||||
"PlatformStatus",
|
"PlatformStatus",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ _CHECKSUM_FLAG_VALUE = 131_072
|
|||||||
|
|
||||||
|
|
||||||
def _strip(message: Dict[str, Any], keys: List[str]) -> Dict[str, Any]:
|
def _strip(message: Dict[str, Any], keys: List[str]) -> Dict[str, Any]:
|
||||||
return {key: value for key, value in message.items() if not key in keys}
|
return {key: value for key, value in message.items() if key not in keys}
|
||||||
|
|
||||||
|
|
||||||
class BfxWebSocketBucket(Connection):
|
class BfxWebSocketBucket(Connection):
|
||||||
@@ -136,7 +136,7 @@ class BfxWebSocketBucket(Connection):
|
|||||||
await self.subscribe(**subscription)
|
await self.subscribe(**subscription)
|
||||||
|
|
||||||
@Connection._require_websocket_connection
|
@Connection._require_websocket_connection
|
||||||
async def close(self, code: int = 1000, reason: str = str()) -> None:
|
async def close(self, code: int = 1000, reason: str = "") -> None:
|
||||||
await self._websocket.close(code, reason)
|
await self._websocket.close(code, reason)
|
||||||
|
|
||||||
def has(self, sub_id: str) -> bool:
|
def has(self, sub_id: str) -> bool:
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class BfxWebSocketClient(Connection):
|
|||||||
type(exception), exception, exception.__traceback__
|
type(exception), exception, exception.__traceback__
|
||||||
)
|
)
|
||||||
|
|
||||||
self.__logger.critical(header + "\n" + str().join(stack_trace)[:-1])
|
self.__logger.critical(f"{header}\n" + str().join(stack_trace)[:-1])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def inputs(self) -> BfxWebSocketInputs:
|
def inputs(self) -> BfxWebSocketInputs:
|
||||||
@@ -141,6 +141,8 @@ class BfxWebSocketClient(Connection):
|
|||||||
try:
|
try:
|
||||||
await task
|
await task
|
||||||
except (ConnectionClosedError, InvalidStatusCode, gaierror) as _e:
|
except (ConnectionClosedError, InvalidStatusCode, gaierror) as _e:
|
||||||
|
nonlocal error
|
||||||
|
|
||||||
if type(error) is not type(_e) or error.args != _e.args:
|
if type(error) is not type(_e) or error.args != _e.args:
|
||||||
raise _e
|
raise _e
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
@@ -241,8 +243,9 @@ class BfxWebSocketClient(Connection):
|
|||||||
if message["version"] != 2:
|
if message["version"] != 2:
|
||||||
raise VersionMismatchError(
|
raise VersionMismatchError(
|
||||||
"Mismatch between the client and the server version: "
|
"Mismatch between the client and the server version: "
|
||||||
+ "please update bitfinex-api-py to the latest version to resolve this error "
|
"please update bitfinex-api-py to the latest version "
|
||||||
+ f"(client version: 2, server version: {message['version']})."
|
f"to resolve this error (client version: 2, server "
|
||||||
|
f"version: {message['version']})."
|
||||||
)
|
)
|
||||||
elif message["event"] == "info" and message["code"] == 20051:
|
elif message["event"] == "info" and message["code"] == 20051:
|
||||||
rcvd = websockets.frames.Close(
|
rcvd = websockets.frames.Close(
|
||||||
@@ -253,8 +256,7 @@ class BfxWebSocketClient(Connection):
|
|||||||
elif message["event"] == "auth":
|
elif message["event"] == "auth":
|
||||||
if message["status"] != "OK":
|
if message["status"] != "OK":
|
||||||
raise InvalidCredentialError(
|
raise InvalidCredentialError(
|
||||||
"Can't authenticate "
|
"Can't authenticate with given API-KEY and API-SECRET."
|
||||||
+ "with given API-KEY and API-SECRET."
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.__event_emitter.emit("authenticated", message)
|
self.__event_emitter.emit("authenticated", message)
|
||||||
@@ -281,14 +283,14 @@ class BfxWebSocketClient(Connection):
|
|||||||
async def subscribe(
|
async def subscribe(
|
||||||
self, channel: str, sub_id: Optional[str] = None, **kwargs: Any
|
self, channel: str, sub_id: Optional[str] = None, **kwargs: Any
|
||||||
) -> None:
|
) -> None:
|
||||||
if not channel in ["ticker", "trades", "book", "candles", "status"]:
|
if channel not in ["ticker", "trades", "book", "candles", "status"]:
|
||||||
raise UnknownChannelError(
|
raise UnknownChannelError(
|
||||||
"Available channels are: " + "ticker, trades, book, candles and status."
|
"Available channels are: ticker, trades, book, candles and status."
|
||||||
)
|
)
|
||||||
|
|
||||||
for bucket in self.__buckets:
|
for bucket in self.__buckets:
|
||||||
if sub_id in bucket.ids:
|
if sub_id in bucket.ids:
|
||||||
raise SubIdError("sub_id must be " + "unique for all subscriptions.")
|
raise SubIdError("sub_id must be unique for all subscriptions.")
|
||||||
|
|
||||||
for bucket in self.__buckets:
|
for bucket in self.__buckets:
|
||||||
if not bucket.is_full:
|
if not bucket.is_full:
|
||||||
@@ -310,7 +312,7 @@ class BfxWebSocketClient(Connection):
|
|||||||
return await bucket.unsubscribe(sub_id)
|
return await bucket.unsubscribe(sub_id)
|
||||||
|
|
||||||
raise UnknownSubscriptionError(
|
raise UnknownSubscriptionError(
|
||||||
"Unable to find " + f"a subscription with sub_id <{sub_id}>."
|
f"Unable to find a subscription with sub_id <{sub_id}>."
|
||||||
)
|
)
|
||||||
|
|
||||||
@Connection._require_websocket_connection
|
@Connection._require_websocket_connection
|
||||||
@@ -320,11 +322,11 @@ class BfxWebSocketClient(Connection):
|
|||||||
return await bucket.resubscribe(sub_id)
|
return await bucket.resubscribe(sub_id)
|
||||||
|
|
||||||
raise UnknownSubscriptionError(
|
raise UnknownSubscriptionError(
|
||||||
"Unable to find " + f"a subscription with sub_id <{sub_id}>."
|
f"Unable to find a subscription with sub_id <{sub_id}>."
|
||||||
)
|
)
|
||||||
|
|
||||||
@Connection._require_websocket_connection
|
@Connection._require_websocket_connection
|
||||||
async def close(self, code: int = 1000, reason: str = str()) -> None:
|
async def close(self, code: int = 1000, reason: str = "") -> None:
|
||||||
for bucket in self.__buckets:
|
for bucket in self.__buckets:
|
||||||
await bucket.close(code=code, reason=reason)
|
await bucket.close(code=code, reason=reason)
|
||||||
|
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ class BfxEventEmitter(AsyncIOEventEmitter):
|
|||||||
) -> Union[_Handler, Callable[[_Handler], _Handler]]:
|
) -> Union[_Handler, Callable[[_Handler], _Handler]]:
|
||||||
if event not in BfxEventEmitter._EVENTS:
|
if event not in BfxEventEmitter._EVENTS:
|
||||||
raise UnknownEventError(
|
raise UnknownEventError(
|
||||||
f"Can't register to unknown event: <{event}> "
|
f"Can't register to unknown event: <{event}> (to get a full"
|
||||||
+ "(to get a full list of available events see https://docs.bitfinex.com/)."
|
"list of available events see https://docs.bitfinex.com/)."
|
||||||
)
|
)
|
||||||
|
|
||||||
return super().on(event, f)
|
return super().on(event, f)
|
||||||
|
|||||||
Binary file not shown.
@@ -3,10 +3,3 @@ profile = "black"
|
|||||||
|
|
||||||
[tool.black]
|
[tool.black]
|
||||||
target-version = ["py38", "py39", "py310", "py311"]
|
target-version = ["py38", "py39", "py310", "py311"]
|
||||||
|
|
||||||
preview = true
|
|
||||||
|
|
||||||
[tool.flake8]
|
|
||||||
max-line-length = 88
|
|
||||||
extend-select = "B950"
|
|
||||||
extend-ignore = ["E203", "E501", "E701"]
|
|
||||||
|
|||||||
Reference in New Issue
Block a user