From 6bf63a7f2fdfcadc6aa84db3f65d3cde79d855b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Thu, 16 Apr 2026 09:03:35 -0700 Subject: [PATCH] Use modern Python type syntax in new DTMF code Replace `Optional[X]` with `X | None`, `List[X]` with `list[X]`, and `Dict[str, Any]` with `dict[str, Any]` in the DTMF frame definitions and Daily transport code added by this branch. --- src/pipecat/frames/frames.py | 8 ++++---- src/pipecat/transports/daily/transport.py | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pipecat/frames/frames.py b/src/pipecat/frames/frames.py index 21780d6cb..bb4d86acd 100644 --- a/src/pipecat/frames/frames.py +++ b/src/pipecat/frames/frames.py @@ -752,8 +752,8 @@ class OutputDTMFFrame(DTMFFrame, DataFrame): :meth:`from_string` to build this from a string like ``"123#"``. """ - button: Optional[KeypadEntry] = None - buttons: Optional[List[KeypadEntry]] = None + button: KeypadEntry | None = None + buttons: list[KeypadEntry] | None = None def __post_init__(self): super().__post_init__() @@ -1296,8 +1296,8 @@ class OutputDTMFUrgentFrame(DTMFFrame, SystemFrame): :meth:`from_string` to build this from a string like ``"123#"``. """ - button: Optional[KeypadEntry] = None - buttons: Optional[List[KeypadEntry]] = None + button: KeypadEntry | None = None + buttons: list[KeypadEntry] | None = None def __post_init__(self): super().__post_init__() diff --git a/src/pipecat/transports/daily/transport.py b/src/pipecat/transports/daily/transport.py index b58701a0b..b7e61fb45 100644 --- a/src/pipecat/transports/daily/transport.py +++ b/src/pipecat/transports/daily/transport.py @@ -171,9 +171,9 @@ class DailyOutputDTMFFrame(OutputDTMFFrame): or ``auto``). When ``None``, Daily's default method is used. """ - session_id: Optional[str] = None - digit_duration_ms: Optional[int] = None - method: Optional[str] = None + session_id: str | None = None + digit_duration_ms: int | None = None + method: str | None = None @dataclass @@ -194,9 +194,9 @@ class DailyOutputDTMFUrgentFrame(OutputDTMFUrgentFrame): or ``auto``). When ``None``, Daily's default method is used. """ - session_id: Optional[str] = None - digit_duration_ms: Optional[int] = None - method: Optional[str] = None + session_id: str | None = None + digit_duration_ms: int | None = None + method: str | None = None class WebRTCVADAnalyzer(VADAnalyzer): @@ -2192,7 +2192,7 @@ class DailyOutputTransport(BaseOutputTransport): if not frame.buttons: return - settings: Dict[str, Any] = {"tones": frame.to_string()} + settings: dict[str, Any] = {"tones": frame.to_string()} if isinstance(frame, (DailyOutputDTMFFrame, DailyOutputDTMFUrgentFrame)): if frame.session_id is not None: settings["sessionId"] = frame.session_id