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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user