You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since Frequenz-SDK is already using Python 3.11 as a minimum version,
Result can now be defined as a union type of the different results
instead of using inheritance.
Copy file name to clipboardExpand all lines: RELEASE_NOTES.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,24 @@
10
10
11
11
- The battery pool metric methods no longer return `None` when no batteries are available. Instead, the value of the `Sample` or `PowerMetric` is set to `None`.
12
12
13
+
- The power distribution `Result` is now a union of all different types of results rather than a base class. This means we can now also use `match` to check for result types instead of only using `isinstance()`. The following example shows how `Result` can be used for matching power distribution results:
14
+
15
+
```python
16
+
from typing import assert_never
17
+
result: Result = some_operation()
18
+
match result:
19
+
case Success() as success:
20
+
print(f"Power request was successful: {success}")
21
+
case PartialFailure() as partial_failure:
22
+
print(f"Power request was partially successful: {partial_failure}")
23
+
case OutOfBounds() as out_of_bounds:
24
+
print(f"Power request was out of bounds: {out_of_bounds}")
25
+
case Error() as error:
26
+
print(f"Power request failed: {error}")
27
+
case _ as unreachable:
28
+
assert_never(unreachable)
29
+
```
30
+
13
31
## New Features
14
32
15
33
<!-- Here goes the main new features and examples or instructions on how to use them -->
0 commit comments