Skip to content

Commit 5dda557

Browse files
bug: use HasField to check explicit field precedence
Signed-off-by: Matthias Wende <[email protected]>
1 parent a029d21 commit 5dda557

File tree

1 file changed

+7
-3
lines changed
  • src/frequenz/client/electricity_trading

1 file changed

+7
-3
lines changed

src/frequenz/client/electricity_trading/_types.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,16 +2002,20 @@ def from_pb(
20022002
Returns:
20032003
PublicOrder object corresponding to the protobuf message.
20042004
"""
2005+
execution_option = (
2006+
OrderExecutionOption.from_pb(public_order.execution_option)
2007+
if public_order.HasField("execution_option")
2008+
else None
2009+
)
2010+
20052011
return cls(
20062012
public_order_id=public_order.id,
20072013
delivery_area=DeliveryArea.from_pb(public_order.delivery_area),
20082014
delivery_period=DeliveryPeriod.from_pb(public_order.delivery_period),
20092015
side=MarketSide.from_pb(public_order.side),
20102016
price=Price.from_pb(public_order.price),
20112017
quantity=Power.from_pb(public_order.quantity),
2012-
execution_option=OrderExecutionOption.from_pb(
2013-
public_order.execution_option
2014-
),
2018+
execution_option=execution_option,
20152019
create_time=public_order.create_time.ToDatetime(tzinfo=timezone.utc),
20162020
update_time=public_order.update_time.ToDatetime(tzinfo=timezone.utc),
20172021
)

0 commit comments

Comments
 (0)