Skip to content

Commit 3fb80a9

Browse files
committed
Make Client.update require named parameters
I noticed it happened often that I used the microgrid id instead of the dispatch id to identify the to-be-updated dispatch which of course is wrong. This should make it more obvious when using the API what kind of ID should be passed. Optimally we have distinct types for Microgrid ID and Dispatch ID though. Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent d42bab9 commit 3fb80a9

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Upgrading
88

99
- The `Dispatch` class is now a frozen dataclass, meaning that it is immutable. Modifications can still be done using `replace`: `dispatch = replace(dispatch, start_time=new_start_time)`.
10+
- The `Client.update()` method now requires named parameters.
1011

1112
## New Features
1213

src/frequenz/client/dispatch/_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ async def create(
166166

167167
async def update(
168168
self,
169+
*,
169170
dispatch_id: int,
170171
new_fields: dict[str, Any],
171172
) -> None:

tests/test_dispatch_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async def test_update_dispatch() -> None:
9999
sample = _update(sample, dispatch)
100100
assert dispatch == sample
101101

102-
await client.update(dispatch.id, {"recurrence.interval": 4})
102+
await client.update(dispatch_id=dispatch.id, new_fields={"recurrence.interval": 4})
103103
assert client.dispatches[0].recurrence.interval == 4
104104

105105

0 commit comments

Comments
 (0)