Skip to content

Commit

Permalink
Fix linting issues that rose after dependency updates
Browse files Browse the repository at this point in the history
Signed-off-by: camille-bouvy-frequenz <camille.bouvy@frequenz.com>
  • Loading branch information
camille-bouvy-frequenz committed Sep 23, 2024
1 parent 9364f16 commit 57036d9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
48 changes: 29 additions & 19 deletions src/frequenz/client/electricity_trading/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def __init__(

self._metadata = (("key", auth_key),) if auth_key else ()

async def stream_gridpool_orders( # pylint: disable=too-many-arguments
async def stream_gridpool_orders(
# pylint: disable=too-many-arguments, too-many-positional-arguments
self,
gridpool_id: int,
order_states: list[OrderState] | None = None,
Expand Down Expand Up @@ -173,10 +174,11 @@ async def stream_gridpool_orders( # pylint: disable=too-many-arguments
_logger.exception(
"Error occurred while streaming gridpool orders: %s", e
)
raise e
raise
return self._gridpool_orders_streams[stream_key].new_receiver()

async def stream_gridpool_trades( # pylint: disable=too-many-arguments
async def stream_gridpool_trades(
# pylint: disable=too-many-arguments, too-many-positional-arguments
self,
gridpool_id: int,
trade_states: list[TradeState] | None = None,
Expand Down Expand Up @@ -231,7 +233,7 @@ async def stream_gridpool_trades( # pylint: disable=too-many-arguments
_logger.exception(
"Error occurred while streaming gridpool trades: %s", e
)
raise e
raise
return self._gridpool_trades_streams[stream_key].new_receiver()

async def stream_public_trades(
Expand Down Expand Up @@ -281,10 +283,11 @@ async def stream_public_trades(
)
except grpc.RpcError as e:
_logger.exception("Error occurred while streaming public trades: %s", e)
raise e
raise
return self._public_trades_streams[public_trade_filter].new_receiver()

def validate_params( # pylint: disable=too-many-arguments
def validate_params(
# pylint: disable=too-many-arguments, too-many-positional-arguments
self,
price: Price | None | _Sentinel = NO_VALUE,
quantity: Energy | None | _Sentinel = NO_VALUE,
Expand Down Expand Up @@ -316,6 +319,7 @@ def validate_params( # pylint: disable=too-many-arguments
Raises:
ValueError: If the parameters are invalid.
NotImplementedError: If the order type is not supported.
"""
if not isinstance(price, _Sentinel) and price is not None:
validate_decimal_places(price.amount, PRECISION_DECIMAL_PRICE, "price")
Expand Down Expand Up @@ -359,7 +363,8 @@ def validate_params( # pylint: disable=too-many-arguments
"Currently only limit orders are supported"
)

async def create_gridpool_order( # pylint: disable=too-many-arguments, too-many-locals
async def create_gridpool_order(
# pylint: disable=too-many-arguments, too-many-positional-arguments, too-many-locals
self,
gridpool_id: int,
delivery_area: DeliveryArea,
Expand Down Expand Up @@ -441,11 +446,12 @@ async def create_gridpool_order( # pylint: disable=too-many-arguments, too-many
)
except grpc.RpcError as e:
_logger.exception("Error occurred while creating gridpool order: %s", e)
raise e
raise

return OrderDetail.from_pb(response.order_detail)

async def update_gridpool_order( # pylint: disable=too-many-arguments, too-many-locals
async def update_gridpool_order(
# pylint: disable=too-many-arguments, too-many-positional-arguments, too-many-locals
self,
gridpool_id: int,
order_id: int,
Expand Down Expand Up @@ -486,6 +492,7 @@ async def update_gridpool_order( # pylint: disable=too-many-arguments, too-many
Raises:
ValueError: If no fields to update are provided.
grpc.RpcError: An error occurred while updating the order.
"""
self.validate_params(
price=price,
Expand Down Expand Up @@ -555,7 +562,7 @@ async def update_gridpool_order( # pylint: disable=too-many-arguments, too-many

except grpc.RpcError as e:
_logger.exception("Error occurred while updating gridpool order: %s", e)
raise e
raise

async def cancel_gridpool_order(
self, gridpool_id: int, order_id: int
Expand Down Expand Up @@ -586,7 +593,7 @@ async def cancel_gridpool_order(
return OrderDetail.from_pb(response.order_detail)
except grpc.RpcError as e:
_logger.exception("Error occurred while cancelling gridpool order: %s", e)
raise e
raise

async def cancel_all_gridpool_orders(self, gridpool_id: int) -> int:
"""
Expand Down Expand Up @@ -617,7 +624,7 @@ async def cancel_all_gridpool_orders(self, gridpool_id: int) -> int:
_logger.exception(
"Error occurred while cancelling all gridpool orders: %s", e
)
raise e
raise

async def get_gridpool_order(self, gridpool_id: int, order_id: int) -> OrderDetail:
"""
Expand Down Expand Up @@ -647,9 +654,10 @@ async def get_gridpool_order(self, gridpool_id: int, order_id: int) -> OrderDeta
return OrderDetail.from_pb(response.order_detail)
except grpc.RpcError as e:
_logger.exception("Error occurred while getting gridpool order: %s", e)
raise e
raise

async def list_gridpool_orders( # pylint: disable=too-many-arguments
async def list_gridpool_orders(
# pylint: disable=too-many-arguments, too-many-positional-arguments
self,
gridpool_id: int,
order_states: list[OrderState] | None = None,
Expand Down Expand Up @@ -718,9 +726,10 @@ async def list_gridpool_orders( # pylint: disable=too-many-arguments
return orders
except grpc.RpcError as e:
_logger.exception("Error occurred while listing gridpool orders: %s", e)
raise e
raise

async def list_gridpool_trades( # pylint: disable=too-many-arguments
async def list_gridpool_trades(
# pylint: disable=too-many-arguments, too-many-positional-arguments
self,
gridpool_id: int,
trade_states: list[TradeState] | None = None,
Expand Down Expand Up @@ -779,9 +788,10 @@ async def list_gridpool_trades( # pylint: disable=too-many-arguments
return [Trade.from_pb(trade) for trade in response.trades]
except grpc.RpcError as e:
_logger.exception("Error occurred while listing gridpool trades: %s", e)
raise e
raise

async def list_public_trades( # pylint: disable=too-many-arguments
async def list_public_trades(
# pylint: disable=too-many-arguments, too-many-positional-arguments
self,
states: list[TradeState] | None = None,
delivery_period: DeliveryPeriod | None = None,
Expand Down Expand Up @@ -837,4 +847,4 @@ async def list_public_trades( # pylint: disable=too-many-arguments
]
except grpc.RpcError as e:
_logger.exception("Error occurred while listing public trades: %s", e)
raise e
raise
2 changes: 1 addition & 1 deletion src/frequenz/client/electricity_trading/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def __init__(
Raises:
ValueError: If the start timestamp does not have a timezone.
ValueError: If the duration is not 5, 15, 30, or 60 minutes.
or if the duration is not 5, 15, 30, or 60 minutes.
"""
if start.tzinfo is None:
raise ValueError("Start timestamp must have a timezone.")
Expand Down
3 changes: 2 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ def test_list_gridpool_orders(
),
],
)
def test_create_gridpool_order_with_invalid_params( # pylint: disable=too-many-arguments
def test_create_gridpool_order_with_invalid_params(
# pylint: disable=too-many-arguments, too-many-positional-arguments
set_up: dict[str, Any],
price: Price,
quantity: Energy,
Expand Down

0 comments on commit 57036d9

Please sign in to comment.