Skip to content

Commit eb69cc5

Browse files
Use HasField to check explicit field presedence (#140)
2 parents a029d21 + 4291bb0 commit eb69cc5

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
# Frequenz Electricity Trading API Client Release Notes
22

3-
## Summary
4-
5-
<!-- Here goes a general summary of what this release is about -->
6-
7-
## Upgrading
8-
9-
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
10-
113
## New Features
124

135
- Update to API v0.7.0
146

157
## Bug Fixes
168

179
- Ensure timestamp conversion errors are surfaced
10+
- Use HasField to check explicit field precedence

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)