Skip to content

Commit e5d9ca7

Browse files
Bump black from 23.12.1 to 24.4.0 (#10)
Bump black from 23.12.1 to 24.4.0 and re-run `black` to have the new formatting.
2 parents 62c8915 + 0f47b04 commit e5d9ca7

File tree

3 files changed

+132
-98
lines changed

3 files changed

+132
-98
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ dev-flake8 = [
4949
"pydoclint == 0.4.1",
5050
"pydocstyle == 6.3.0",
5151
]
52-
dev-formatting = ["black == 23.12.1", "isort == 5.13.2"]
52+
dev-formatting = ["black == 24.4.0", "isort == 5.13.2"]
5353
dev-mkdocs = [
54-
"black == 23.12.1",
54+
"black == 24.4.0",
5555
"Markdown==3.6",
5656
"mike == 2.0.0",
5757
"mkdocs-gen-files == 0.5.0",

src/frequenz/client/electricity_trading/_client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -379,18 +379,18 @@ async def update_gridpool_order( # pylint: disable=too-many-arguments, too-many
379379
price=None if price is NO_VALUE else price, # type: ignore
380380
quantity=None if quantity is NO_VALUE else quantity, # type: ignore
381381
stop_price=None if stop_price is NO_VALUE else stop_price, # type: ignore
382-
peak_price_delta=None
383-
if peak_price_delta is NO_VALUE
384-
else peak_price_delta, # type: ignore
385-
display_quantity=None
386-
if display_quantity is NO_VALUE
387-
else display_quantity, # type: ignore
388-
execution_option=None
389-
if execution_option is NO_VALUE
390-
else execution_option, # type: ignore
391-
valid_until=None
392-
if valid_until is NO_VALUE
393-
else valid_until, # type: ignore
382+
peak_price_delta=(
383+
None if peak_price_delta is NO_VALUE else peak_price_delta # type: ignore
384+
),
385+
display_quantity=(
386+
None if display_quantity is NO_VALUE else display_quantity # type: ignore
387+
),
388+
execution_option=(
389+
None if execution_option is NO_VALUE else execution_option # type: ignore
390+
),
391+
valid_until=(
392+
None if valid_until is NO_VALUE else valid_until # type: ignore
393+
),
394394
payload=None if payload is NO_VALUE else payload, # type: ignore
395395
tag=None if tag is NO_VALUE else tag, # type: ignore
396396
)

src/frequenz/client/electricity_trading/_types.py

Lines changed: 118 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -971,21 +971,31 @@ def from_pb(cls, order: electricity_trading_pb2.Order) -> Self:
971971
side=MarketSide.from_pb(order.side),
972972
price=Price.from_pb(order.price),
973973
quantity=Energy.from_pb(order.quantity),
974-
stop_price=Price.from_pb(order.stop_price)
975-
if order.HasField("stop_price")
976-
else None,
977-
peak_price_delta=Price.from_pb(order.peak_price_delta)
978-
if order.HasField("peak_price_delta")
979-
else None,
980-
display_quantity=Energy.from_pb(order.display_quantity)
981-
if order.HasField("display_quantity")
982-
else None,
983-
execution_option=OrderExecutionOption.from_pb(order.execution_option)
984-
if order.HasField("execution_option")
985-
else None,
986-
valid_until=order.valid_until.ToDatetime(tzinfo=timezone.utc)
987-
if order.HasField("valid_until")
988-
else None,
974+
stop_price=(
975+
Price.from_pb(order.stop_price)
976+
if order.HasField("stop_price")
977+
else None
978+
),
979+
peak_price_delta=(
980+
Price.from_pb(order.peak_price_delta)
981+
if order.HasField("peak_price_delta")
982+
else None
983+
),
984+
display_quantity=(
985+
Energy.from_pb(order.display_quantity)
986+
if order.HasField("display_quantity")
987+
else None
988+
),
989+
execution_option=(
990+
OrderExecutionOption.from_pb(order.execution_option)
991+
if order.HasField("execution_option")
992+
else None
993+
),
994+
valid_until=(
995+
order.valid_until.ToDatetime(tzinfo=timezone.utc)
996+
if order.HasField("valid_until")
997+
else None
998+
),
989999
payload=json_format.MessageToDict(order.payload) if order.payload else None,
9901000
tag=order.tag if order.tag else None,
9911001
)
@@ -1010,12 +1020,12 @@ def to_pb(self) -> electricity_trading_pb2.Order:
10101020
price=self.price.to_pb(),
10111021
quantity=self.quantity.to_pb(),
10121022
stop_price=self.stop_price.to_pb() if self.stop_price else None,
1013-
peak_price_delta=self.peak_price_delta.to_pb()
1014-
if self.peak_price_delta
1015-
else None,
1016-
display_quantity=self.display_quantity.to_pb()
1017-
if self.display_quantity
1018-
else None,
1023+
peak_price_delta=(
1024+
self.peak_price_delta.to_pb() if self.peak_price_delta else None
1025+
),
1026+
display_quantity=(
1027+
self.display_quantity.to_pb() if self.display_quantity else None
1028+
),
10191029
execution_option=(
10201030
electricity_trading_pb2.OrderExecutionOption.ValueType(
10211031
self.execution_option.value
@@ -1415,18 +1425,22 @@ def to_pb(self) -> electricity_trading_pb2.GridpoolOrderFilter:
14151425
Protobuf GridpoolOrderFilter corresponding to the object.
14161426
"""
14171427
return electricity_trading_pb2.GridpoolOrderFilter(
1418-
states=[
1419-
electricity_trading_pb2.OrderState.ValueType(state.value)
1420-
for state in self.order_states
1421-
]
1422-
if self.order_states
1423-
else None,
1424-
side=electricity_trading_pb2.MarketSide.ValueType(self.side.value)
1425-
if self.side
1426-
else None,
1427-
delivery_period=self.delivery_period.to_pb()
1428-
if self.delivery_period
1429-
else None,
1428+
states=(
1429+
[
1430+
electricity_trading_pb2.OrderState.ValueType(state.value)
1431+
for state in self.order_states
1432+
]
1433+
if self.order_states
1434+
else None
1435+
),
1436+
side=(
1437+
electricity_trading_pb2.MarketSide.ValueType(self.side.value)
1438+
if self.side
1439+
else None
1440+
),
1441+
delivery_period=(
1442+
self.delivery_period.to_pb() if self.delivery_period else None
1443+
),
14301444
delivery_area=self.delivery_area.to_pb() if self.delivery_area else None,
14311445
tag=self.tag if self.tag else None,
14321446
)
@@ -1520,14 +1534,16 @@ def to_pb(self) -> electricity_trading_pb2.GridpoolTradeFilter:
15201534
Protobuf GridpoolTradeFilter corresponding to the object.
15211535
"""
15221536
return electricity_trading_pb2.GridpoolTradeFilter(
1523-
states=[TradeState.to_pb(state) for state in self.trade_states]
1524-
if self.trade_states
1525-
else None,
1537+
states=(
1538+
[TradeState.to_pb(state) for state in self.trade_states]
1539+
if self.trade_states
1540+
else None
1541+
),
15261542
trade_ids=self.trade_ids if self.trade_ids else None,
15271543
side=MarketSide.to_pb(self.side) if self.side else None,
1528-
delivery_period=self.delivery_period.to_pb()
1529-
if self.delivery_period
1530-
else None,
1544+
delivery_period=(
1545+
self.delivery_period.to_pb() if self.delivery_period else None
1546+
),
15311547
delivery_area=self.delivery_area.to_pb() if self.delivery_area else None,
15321548
)
15331549

@@ -1613,21 +1629,23 @@ def to_pb(self) -> electricity_trading_pb2.PublicTradeFilter:
16131629
Protobuf PublicTradeFilter corresponding to the object.
16141630
"""
16151631
return electricity_trading_pb2.PublicTradeFilter(
1616-
states=[
1617-
electricity_trading_pb2.TradeState.ValueType(state.value)
1618-
for state in self.states
1619-
]
1620-
if self.states
1621-
else None,
1622-
delivery_period=self.delivery_period.to_pb()
1623-
if self.delivery_period
1624-
else None,
1625-
buy_delivery_area=self.buy_delivery_area.to_pb()
1626-
if self.buy_delivery_area
1627-
else None,
1628-
sell_delivery_area=self.sell_delivery_area.to_pb()
1629-
if self.sell_delivery_area
1630-
else None,
1632+
states=(
1633+
[
1634+
electricity_trading_pb2.TradeState.ValueType(state.value)
1635+
for state in self.states
1636+
]
1637+
if self.states
1638+
else None
1639+
),
1640+
delivery_period=(
1641+
self.delivery_period.to_pb() if self.delivery_period else None
1642+
),
1643+
buy_delivery_area=(
1644+
self.buy_delivery_area.to_pb() if self.buy_delivery_area else None
1645+
),
1646+
sell_delivery_area=(
1647+
self.sell_delivery_area.to_pb() if self.sell_delivery_area else None
1648+
),
16311649
)
16321650

16331651

@@ -1695,30 +1713,46 @@ def from_pb(
16951713
UpdateOrder object corresponding to the protobuf message.
16961714
"""
16971715
return cls(
1698-
price=Price.from_pb(update_order.price)
1699-
if update_order.HasField("price")
1700-
else None,
1701-
quantity=Energy.from_pb(update_order.quantity)
1702-
if update_order.HasField("quantity")
1703-
else None,
1704-
stop_price=Price.from_pb(update_order.stop_price)
1705-
if update_order.HasField("stop_price")
1706-
else None,
1707-
peak_price_delta=Price.from_pb(update_order.peak_price_delta)
1708-
if update_order.HasField("peak_price_delta")
1709-
else None,
1710-
display_quantity=Energy.from_pb(update_order.display_quantity)
1711-
if update_order.HasField("display_quantity")
1712-
else None,
1713-
execution_option=OrderExecutionOption.from_pb(update_order.execution_option)
1714-
if update_order.HasField("execution_option")
1715-
else None,
1716-
valid_until=update_order.valid_until.ToDatetime(tzinfo=timezone.utc)
1717-
if update_order.HasField("valid_until")
1718-
else None,
1719-
payload=json_format.MessageToDict(update_order.payload)
1720-
if update_order.payload
1721-
else None,
1716+
price=(
1717+
Price.from_pb(update_order.price)
1718+
if update_order.HasField("price")
1719+
else None
1720+
),
1721+
quantity=(
1722+
Energy.from_pb(update_order.quantity)
1723+
if update_order.HasField("quantity")
1724+
else None
1725+
),
1726+
stop_price=(
1727+
Price.from_pb(update_order.stop_price)
1728+
if update_order.HasField("stop_price")
1729+
else None
1730+
),
1731+
peak_price_delta=(
1732+
Price.from_pb(update_order.peak_price_delta)
1733+
if update_order.HasField("peak_price_delta")
1734+
else None
1735+
),
1736+
display_quantity=(
1737+
Energy.from_pb(update_order.display_quantity)
1738+
if update_order.HasField("display_quantity")
1739+
else None
1740+
),
1741+
execution_option=(
1742+
OrderExecutionOption.from_pb(update_order.execution_option)
1743+
if update_order.HasField("execution_option")
1744+
else None
1745+
),
1746+
valid_until=(
1747+
update_order.valid_until.ToDatetime(tzinfo=timezone.utc)
1748+
if update_order.HasField("valid_until")
1749+
else None
1750+
),
1751+
payload=(
1752+
json_format.MessageToDict(update_order.payload)
1753+
if update_order.payload
1754+
else None
1755+
),
17221756
tag=update_order.tag if update_order.HasField("tag") else None,
17231757
)
17241758

@@ -1737,12 +1771,12 @@ def to_pb(self) -> electricity_trading_pb2.UpdateGridpoolOrderRequest.UpdateOrde
17371771
price=self.price.to_pb() if self.price else None,
17381772
quantity=self.quantity.to_pb() if self.quantity else None,
17391773
stop_price=self.stop_price.to_pb() if self.stop_price else None,
1740-
peak_price_delta=self.peak_price_delta.to_pb()
1741-
if self.peak_price_delta
1742-
else None,
1743-
display_quantity=self.display_quantity.to_pb()
1744-
if self.display_quantity
1745-
else None,
1774+
peak_price_delta=(
1775+
self.peak_price_delta.to_pb() if self.peak_price_delta else None
1776+
),
1777+
display_quantity=(
1778+
self.display_quantity.to_pb() if self.display_quantity else None
1779+
),
17461780
execution_option=(
17471781
electricity_trading_pb2.OrderExecutionOption.ValueType(
17481782
self.execution_option.value

0 commit comments

Comments
 (0)