From ab00ff9daf5b9ea891441d79f9eeaabca10d1f7e Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:59:26 +0000 Subject: [PATCH] reformat --- binance/async_client.py | 28 +++++++++++++++++----------- binance/client.py | 28 +++++++++++++++++----------- binance/exceptions.py | 3 ++- binance/ws/reconnecting_websocket.py | 10 ++++++---- binance/ws/threaded_stream.py | 3 ++- tests/test_async_client.py | 1 + tests/test_client.py | 1 + tests/test_cryptography.py | 6 +++--- 8 files changed, 49 insertions(+), 31 deletions(-) diff --git a/binance/async_client.py b/binance/async_client.py index a7503f56e..d0efec2bd 100644 --- a/binance/async_client.py +++ b/binance/async_client.py @@ -629,9 +629,11 @@ async def order_limit(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params): order_limit.__doc__ = Client.order_limit.__doc__ async def order_limit_buy(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params): - params.update({ - "side": self.SIDE_BUY, - }) + params.update( + { + "side": self.SIDE_BUY, + } + ) return await self.order_limit(timeInForce=timeInForce, **params) order_limit_buy.__doc__ = Client.order_limit_buy.__doc__ @@ -710,7 +712,7 @@ async def get_account(self, **params): get_account.__doc__ = Client.get_account.__doc__ - async def get_asset_balance(self, asset = None, **params): + async def get_asset_balance(self, asset=None, **params): res = await self.get_account(**params) # find asset balance in list of balances if "balances" in res: @@ -3263,10 +3265,12 @@ async def ws_order_limit(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **param :returns: WS response See order endpoint for full response options """ - params.update({ - "type": self.ORDER_TYPE_LIMIT, - "timeInForce": timeInForce, - }) + params.update( + { + "type": self.ORDER_TYPE_LIMIT, + "timeInForce": timeInForce, + } + ) return await self.ws_create_order(**params) async def ws_order_limit_buy( @@ -3295,9 +3299,11 @@ async def ws_order_limit_buy( :returns: WS response See order endpoint for full response options """ - params.update({ - "side": self.SIDE_BUY, - }) + params.update( + { + "side": self.SIDE_BUY, + } + ) return await self.ws_order_limit(timeInForce=timeInForce, **params) async def ws_order_limit_sell( diff --git a/binance/client.py b/binance/client.py index c5641e5da..96a2a9476 100755 --- a/binance/client.py +++ b/binance/client.py @@ -1359,9 +1359,11 @@ def order_limit_buy(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params): :raises: BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException """ - params.update({ - "side": self.SIDE_BUY, - }) + params.update( + { + "side": self.SIDE_BUY, + } + ) return self.order_limit(timeInForce=timeInForce, **params) def order_limit_sell(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params): @@ -1997,7 +1999,7 @@ def get_account(self, **params): """ return self._get("account", True, data=params) - def get_asset_balance(self, asset = None, **params): + def get_asset_balance(self, asset=None, **params): """Get current asset balance. :param asset: optional - the asset to get the balance of @@ -10201,10 +10203,12 @@ def ws_order_limit(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params): :returns: WS response See order endpoint for full response options """ - params.update({ - "type": self.ORDER_TYPE_LIMIT, - "timeInForce": timeInForce, - }) + params.update( + { + "type": self.ORDER_TYPE_LIMIT, + "timeInForce": timeInForce, + } + ) return self.ws_create_order(**params) def ws_order_limit_buy(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params): @@ -10231,9 +10235,11 @@ def ws_order_limit_buy(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params) :returns: WS response See order endpoint for full response options """ - params.update({ - "side": self.SIDE_BUY, - }) + params.update( + { + "side": self.SIDE_BUY, + } + ) return self.ws_order_limit(timeInForce=timeInForce, **params) def ws_order_limit_sell(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params): diff --git a/binance/exceptions.py b/binance/exceptions.py index 44753f567..62fcefb97 100644 --- a/binance/exceptions.py +++ b/binance/exceptions.py @@ -79,4 +79,5 @@ def __init__(self, value): super().__init__(message) -class UnknownDateFormat(Exception): ... +class UnknownDateFormat(Exception): + ... diff --git a/binance/ws/reconnecting_websocket.py b/binance/ws/reconnecting_websocket.py index f53cd717c..b0bfdba1c 100644 --- a/binance/ws/reconnecting_websocket.py +++ b/binance/ws/reconnecting_websocket.py @@ -149,10 +149,12 @@ async def _read_loop(self): self._log.debug( f"Queue overflow {self.MAX_QUEUE_SIZE}. Message not filled" ) - await self._queue.put({ - "e": "error", - "m": "Queue overflow. Message not filled", - }) + await self._queue.put( + { + "e": "error", + "m": "Queue overflow. Message not filled", + } + ) raise BinanceWebsocketUnableToConnect except asyncio.TimeoutError: self._log.debug(f"no message in {self.TIMEOUT} seconds") diff --git a/binance/ws/threaded_stream.py b/binance/ws/threaded_stream.py index e2fc575f9..a0115a1b0 100755 --- a/binance/ws/threaded_stream.py +++ b/binance/ws/threaded_stream.py @@ -32,7 +32,8 @@ def __init__( "session_params": session_params, } - async def _before_socket_listener_start(self): ... + async def _before_socket_listener_start(self): + ... async def socket_listener(self): self._client = await AsyncClient.create(loop=self._loop, **self._client_params) diff --git a/tests/test_async_client.py b/tests/test_async_client.py index 93fa4f031..d7c32fb33 100644 --- a/tests/test_async_client.py +++ b/tests/test_async_client.py @@ -84,6 +84,7 @@ async def test_get_asset_balance(clientAsync): async def test_get_asset_balance_no_asset_provided(clientAsync): await clientAsync.get_asset_balance() + async def test_get_my_trades(clientAsync): await clientAsync.get_my_trades(symbol="BTCUSDT") diff --git a/tests/test_client.py b/tests/test_client.py index fd10fe74d..281060ec4 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -82,6 +82,7 @@ def test_get_asset_balance(client): def test_get_asset_balance_no_asset_provided(client): client.get_asset_balance() + def test_get_my_trades(client): client.get_my_trades(symbol="BTCUSDT") diff --git a/tests/test_cryptography.py b/tests/test_cryptography.py index 8048fda36..04240262d 100644 --- a/tests/test_cryptography.py +++ b/tests/test_cryptography.py @@ -47,6 +47,6 @@ def test_encryption(): ping=False, ) signature = client._generate_signature(data) - assert signature == case["expected_signature"], ( - f"Test failed: {case['description']}" - ) + assert ( + signature == case["expected_signature"] + ), f"Test failed: {case['description']}"