From e11b48631230fe5affd0dbaf9aaf6598f3c6e4aa Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Tue, 17 Mar 2026 08:54:07 -0400 Subject: [PATCH] fix: clean up configure() type hints, deduplicate token expiry, and improve comment Narrow misleading Optional type hints on parameters that never accept None, extract the duplicated token_exp_duration * 60 * 60 calculation, remove unnecessary forward-reference quotes on DailyMeetingTokenProperties, and clarify why enable_dialout is explicitly set to False. --- changelog/4048.changed.md | 1 + src/pipecat/runner/daily.py | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 changelog/4048.changed.md diff --git a/changelog/4048.changed.md b/changelog/4048.changed.md new file mode 100644 index 000000000..e5b9aab06 --- /dev/null +++ b/changelog/4048.changed.md @@ -0,0 +1 @@ +- Narrowed misleading `Optional` type hints and deduplicated token expiry calculation in `configure()` (`pipecat.runner.daily`). diff --git a/src/pipecat/runner/daily.py b/src/pipecat/runner/daily.py index d61f14381..099d931a4 100644 --- a/src/pipecat/runner/daily.py +++ b/src/pipecat/runner/daily.py @@ -79,16 +79,16 @@ async def configure( aiohttp_session: aiohttp.ClientSession, *, api_key: Optional[str] = None, - room_exp_duration: Optional[float] = 2.0, - token_exp_duration: Optional[float] = 2.0, + room_exp_duration: float = 2.0, + token_exp_duration: float = 2.0, sip_caller_phone: Optional[str] = None, - sip_enable_video: Optional[bool] = False, - sip_num_endpoints: Optional[int] = 1, + sip_enable_video: bool = False, + sip_num_endpoints: int = 1, sip_codecs: Optional[Dict[str, List[str]]] = None, sip_provider: Optional[str] = None, room_geo: Optional[str] = None, room_properties: Optional[DailyRoomProperties] = None, - token_properties: Optional["DailyMeetingTokenProperties"] = None, + token_properties: Optional[DailyMeetingTokenProperties] = None, ) -> DailyRoomConfig: """Configure Daily room URL and token with optional SIP capabilities. @@ -184,6 +184,8 @@ async def configure( aiohttp_session=aiohttp_session, ) + token_expiry_seconds: float = token_exp_duration * 60 * 60 + # Check for existing room URL (only in standard mode) existing_room_url = os.getenv("DAILY_ROOM_URL") if existing_room_url and not sip_enabled: @@ -192,11 +194,12 @@ async def configure( room_url = existing_room_url # Create token and return standard format - expiry_time: float = token_exp_duration * 60 * 60 token_params = None if token_properties: token_params = DailyMeetingTokenParams(properties=token_properties) - token = await daily_rest_helper.get_token(room_url, expiry_time, params=token_params) + token = await daily_rest_helper.get_token( + room_url, token_expiry_seconds, params=token_params + ) return DailyRoomConfig(room_url=room_url, token=token) # Create a new room @@ -229,7 +232,10 @@ async def configure( provider=sip_provider, ) room_properties.sip = sip_params - room_properties.enable_dialout = False # Requires dialout entitlement on Daily plan + # Explicitly disable dialout to prevent room creation failures on + # accounts where dialout defaults to enabled but the plan lacks the + # required dialout entitlement. + room_properties.enable_dialout = False room_properties.start_video_off = not sip_enable_video # Voice-only by default # Create room parameters @@ -241,7 +247,6 @@ async def configure( logger.info(f"Created Daily room: {room_url}") # Create meeting token - token_expiry_seconds = token_exp_duration * 60 * 60 token_params = None if token_properties: token_params = DailyMeetingTokenParams(properties=token_properties)