mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-18 06:14: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):
|
||||
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
|
||||
from copy import copy
|
||||
|
||||
from logging import *
|
||||
from logging import FileHandler, Formatter, Logger, LogRecord, StreamHandler
|
||||
from typing import TYPE_CHECKING, Literal, Optional
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -178,8 +178,10 @@ class RestMerchantEndpoints(Middleware):
|
||||
def get_merchant_settings(self, key: str) -> Any:
|
||||
return self._post("auth/r/ext/pay/settings/get", body={"key": key})
|
||||
|
||||
def list_merchant_settings(self, keys: List[str] = []) -> Dict[str, Any]:
|
||||
return self._post("auth/r/ext/pay/settings/list", body={"keys": keys})
|
||||
def list_merchant_settings(
|
||||
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(
|
||||
self,
|
||||
|
||||
@@ -24,7 +24,8 @@ def partial(cls):
|
||||
|
||||
if len(kwargs) != 0:
|
||||
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__
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
from . import dataclasses
|
||||
|
||||
from .labeler import (
|
||||
from .labeler import ( # noqa: F401
|
||||
_Serializer,
|
||||
generate_labeler_serializer,
|
||||
generate_recursive_serializer,
|
||||
)
|
||||
|
||||
from .notification import _Notification
|
||||
from .notification import _Notification # noqa: F401
|
||||
|
||||
__serializers__ = [
|
||||
"PlatformStatus",
|
||||
|
||||
@@ -15,7 +15,7 @@ _CHECKSUM_FLAG_VALUE = 131_072
|
||||
|
||||
|
||||
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):
|
||||
@@ -136,7 +136,7 @@ class BfxWebSocketBucket(Connection):
|
||||
await self.subscribe(**subscription)
|
||||
|
||||
@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)
|
||||
|
||||
def has(self, sub_id: str) -> bool:
|
||||
|
||||
@@ -100,7 +100,7 @@ class BfxWebSocketClient(Connection):
|
||||
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
|
||||
def inputs(self) -> BfxWebSocketInputs:
|
||||
@@ -141,6 +141,8 @@ class BfxWebSocketClient(Connection):
|
||||
try:
|
||||
await task
|
||||
except (ConnectionClosedError, InvalidStatusCode, gaierror) as _e:
|
||||
nonlocal error
|
||||
|
||||
if type(error) is not type(_e) or error.args != _e.args:
|
||||
raise _e
|
||||
except asyncio.CancelledError:
|
||||
@@ -241,8 +243,9 @@ class BfxWebSocketClient(Connection):
|
||||
if message["version"] != 2:
|
||||
raise VersionMismatchError(
|
||||
"Mismatch between the client and the server version: "
|
||||
+ "please update bitfinex-api-py to the latest version to resolve this error "
|
||||
+ f"(client version: 2, server version: {message['version']})."
|
||||
"please update bitfinex-api-py to the latest version "
|
||||
f"to resolve this error (client version: 2, server "
|
||||
f"version: {message['version']})."
|
||||
)
|
||||
elif message["event"] == "info" and message["code"] == 20051:
|
||||
rcvd = websockets.frames.Close(
|
||||
@@ -253,8 +256,7 @@ class BfxWebSocketClient(Connection):
|
||||
elif message["event"] == "auth":
|
||||
if message["status"] != "OK":
|
||||
raise InvalidCredentialError(
|
||||
"Can't authenticate "
|
||||
+ "with given API-KEY and API-SECRET."
|
||||
"Can't authenticate with given API-KEY and API-SECRET."
|
||||
)
|
||||
|
||||
self.__event_emitter.emit("authenticated", message)
|
||||
@@ -281,14 +283,14 @@ class BfxWebSocketClient(Connection):
|
||||
async def subscribe(
|
||||
self, channel: str, sub_id: Optional[str] = None, **kwargs: Any
|
||||
) -> None:
|
||||
if not channel in ["ticker", "trades", "book", "candles", "status"]:
|
||||
if channel not in ["ticker", "trades", "book", "candles", "status"]:
|
||||
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:
|
||||
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:
|
||||
if not bucket.is_full:
|
||||
@@ -310,7 +312,7 @@ class BfxWebSocketClient(Connection):
|
||||
return await bucket.unsubscribe(sub_id)
|
||||
|
||||
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
|
||||
@@ -320,11 +322,11 @@ class BfxWebSocketClient(Connection):
|
||||
return await bucket.resubscribe(sub_id)
|
||||
|
||||
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
|
||||
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:
|
||||
await bucket.close(code=code, reason=reason)
|
||||
|
||||
|
||||
@@ -105,8 +105,8 @@ class BfxEventEmitter(AsyncIOEventEmitter):
|
||||
) -> Union[_Handler, Callable[[_Handler], _Handler]]:
|
||||
if event not in BfxEventEmitter._EVENTS:
|
||||
raise UnknownEventError(
|
||||
f"Can't register to unknown event: <{event}> "
|
||||
+ "(to get a full list of available events see https://docs.bitfinex.com/)."
|
||||
f"Can't register to unknown event: <{event}> (to get a full"
|
||||
"list of available events see https://docs.bitfinex.com/)."
|
||||
)
|
||||
|
||||
return super().on(event, f)
|
||||
|
||||
Binary file not shown.
@@ -3,10 +3,3 @@ profile = "black"
|
||||
|
||||
[tool.black]
|
||||
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