From 5c86dc901b5cd7d10c8e55ada7f5e4fb41eee8a0 Mon Sep 17 00:00:00 2001 From: "Mathias L. Baumann" Date: Wed, 4 Jun 2025 17:24:31 +0200 Subject: [PATCH] Make all parameters of streamers `new_receiver` named Signed-off-by: Mathias L. Baumann --- RELEASE_NOTES.md | 8 +++++++- src/frequenz/client/base/streaming.py | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 22740c9..71cd7c8 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -12,11 +12,17 @@ If calling this function manually and passing `ChannelOptions`, it is recommended to switch to passing `ChannelOptions` via keyword argument. +* All parameters of the Streamers `new_receiver` method are now keyword-only arguments. This means that you must specify them by name when calling the method, e.g.: + + ```python + recv = streamer.new_receiver(max_size=50, warn_on_overflow=True) + ``` + ## New Features * The streaming client, when using `new_receiver(include_events=True)`, will now return a receiver that yields stream notification events, such as `StreamStarted`, `StreamRetrying`, and `StreamFatalError`. This allows you to monitor the state of the stream: - ```python + ```python recv = streamer.new_receiver(include_events=True) for msg in recv: diff --git a/src/frequenz/client/base/streaming.py b/src/frequenz/client/base/streaming.py index 61610ad..b0ad98e 100644 --- a/src/frequenz/client/base/streaming.py +++ b/src/frequenz/client/base/streaming.py @@ -194,26 +194,26 @@ def __init__( # pylint: disable=too-many-arguments,too-many-positional-argument @overload def new_receiver( self, + *, maxsize: int = 50, warn_on_overflow: bool = True, - *, include_events: Literal[False] = False, ) -> channels.Receiver[OutputT]: ... @overload def new_receiver( self, + *, maxsize: int = 50, warn_on_overflow: bool = True, - *, include_events: Literal[True], ) -> channels.Receiver[StreamEvent | OutputT]: ... def new_receiver( self, + *, maxsize: int = 50, warn_on_overflow: bool = True, - *, include_events: bool = False, ) -> channels.Receiver[OutputT] | channels.Receiver[StreamEvent | OutputT]: """Create a new receiver for the stream.