From b9ff33365482bf25f6d31829a18ba59d450d9775 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Thu, 23 Apr 2026 18:06:54 -0400 Subject: [PATCH] fix(types): admit None on settings fields that accept it as a default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Service-specific Settings subclasses declared fields as T | _NotGiven (no None), but the services routinely pass None to those fields during init to mean "don't override — use the vendor's default". The field type just didn't reflect that a None value is valid, so pyright flagged every None at the call sites. Change the declarations to T | None | _NotGiven, matching the pattern already used by ServiceSettings.model and TTSSettings.language. No constructor-call changes; the default_factory stays NOT_GIVEN. Fields touched across 11 files: - services/settings.py: TTSSettings.voice (base class; covers asyncai, cartesia, elevenlabs, fish, hume, kokoro, lmnt, mistral, neuphonic, piper, resembleai, rime, xtts TTS services). - services/aws/llm.py: latency. - services/aws/tts.py: engine, pitch, rate, volume, lexicon_names. - services/azure/tts.py: emphasis, pitch, rate, role, style, style_degree, volume. - services/google/gemini_live/llm.py: vad. - services/google/llm.py: thinking. - services/google/stt.py: language_codes. - services/inworld/tts.py: speaking_rate, temperature. - services/openai/tts.py: instructions, speed. - services/speechmatics/stt.py: 13 fields (domain, operating_point, max_delay, end_of_utterance_*, punctuation_overrides, *_partials, split_sentences, enable_diarization, speaker_*, max_speakers, prefer_current_speaker, extra_params). - services/ultravox/llm.py: output_medium. Clears 94 pyright errors (1035 -> 941). --- src/pipecat/services/aws/llm.py | 2 +- src/pipecat/services/aws/tts.py | 10 +++---- src/pipecat/services/azure/tts.py | 14 ++++----- .../services/google/gemini_live/llm.py | 2 +- src/pipecat/services/google/llm.py | 2 +- src/pipecat/services/google/stt.py | 2 +- src/pipecat/services/inworld/tts.py | 4 +-- src/pipecat/services/openai/tts.py | 4 +-- src/pipecat/services/settings.py | 2 +- src/pipecat/services/speechmatics/stt.py | 30 +++++++++++-------- src/pipecat/services/ultravox/llm.py | 2 +- 11 files changed, 39 insertions(+), 35 deletions(-) diff --git a/src/pipecat/services/aws/llm.py b/src/pipecat/services/aws/llm.py index bf226d815..5420addf0 100644 --- a/src/pipecat/services/aws/llm.py +++ b/src/pipecat/services/aws/llm.py @@ -67,7 +67,7 @@ class AWSBedrockLLMSettings(LLMSettings): """ stop_sequences: list[str] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - latency: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + latency: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) enable_prompt_caching: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) additional_model_request_fields: dict[str, Any] | _NotGiven = field( default_factory=lambda: NOT_GIVEN diff --git a/src/pipecat/services/aws/tts.py b/src/pipecat/services/aws/tts.py index 93919c860..d49aa796a 100644 --- a/src/pipecat/services/aws/tts.py +++ b/src/pipecat/services/aws/tts.py @@ -133,11 +133,11 @@ class AWSPollyTTSSettings(TTSSettings): lexicon_names: List of pronunciation lexicons to apply. """ - engine: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - pitch: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - rate: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - volume: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - lexicon_names: list[str] | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + engine: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pitch: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + rate: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + volume: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + lexicon_names: list[str] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) class AWSPollyTTSService(TTSService): diff --git a/src/pipecat/services/azure/tts.py b/src/pipecat/services/azure/tts.py index 46811a1a3..4e6879d1a 100644 --- a/src/pipecat/services/azure/tts.py +++ b/src/pipecat/services/azure/tts.py @@ -80,13 +80,13 @@ class AzureTTSSettings(TTSSettings): volume: Volume level (e.g., "+20%", "loud", "x-soft"). """ - emphasis: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - pitch: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - rate: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - role: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - style: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - style_degree: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - volume: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + emphasis: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pitch: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + rate: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + role: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + style: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + style_degree: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + volume: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) class AzureBaseTTSService: diff --git a/src/pipecat/services/google/gemini_live/llm.py b/src/pipecat/services/google/gemini_live/llm.py index b4ced161f..7c0c22933 100644 --- a/src/pipecat/services/google/gemini_live/llm.py +++ b/src/pipecat/services/google/gemini_live/llm.py @@ -342,7 +342,7 @@ class GeminiLiveLLMSettings(LLMSettings): modalities: GeminiModalities | _NotGiven = field(default_factory=lambda: NOT_GIVEN) language: Language | str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) media_resolution: GeminiMediaResolution | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - vad: GeminiVADParams | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + vad: GeminiVADParams | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) context_window_compression: ContextWindowCompressionParams | dict | _NotGiven = field( default_factory=lambda: NOT_GIVEN ) diff --git a/src/pipecat/services/google/llm.py b/src/pipecat/services/google/llm.py index e5e4fd5b6..faba2868b 100644 --- a/src/pipecat/services/google/llm.py +++ b/src/pipecat/services/google/llm.py @@ -107,7 +107,7 @@ class GoogleLLMSettings(LLMSettings): thinking: Thinking configuration. """ - thinking: Union["GoogleLLMService.ThinkingConfig", _NotGiven] = field( + thinking: Union["GoogleLLMService.ThinkingConfig", None, _NotGiven] = field( default_factory=lambda: NOT_GIVEN ) diff --git a/src/pipecat/services/google/stt.py b/src/pipecat/services/google/stt.py index b34056ee2..d9fb0a160 100644 --- a/src/pipecat/services/google/stt.py +++ b/src/pipecat/services/google/stt.py @@ -385,7 +385,7 @@ class GoogleSTTSettings(STTSettings): """ languages: list[Language] | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - language_codes: list[str] | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + language_codes: list[str] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) use_separate_recognition_per_channel: bool | _NotGiven = field( default_factory=lambda: NOT_GIVEN ) diff --git a/src/pipecat/services/inworld/tts.py b/src/pipecat/services/inworld/tts.py index 33c332384..ef3f0f956 100644 --- a/src/pipecat/services/inworld/tts.py +++ b/src/pipecat/services/inworld/tts.py @@ -72,8 +72,8 @@ class InworldTTSSettings(TTSSettings): temperature: Temperature for speech synthesis. """ - speaking_rate: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - temperature: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + speaking_rate: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + temperature: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) _aliases: ClassVar[dict[str, str]] = { "voiceId": "voice", diff --git a/src/pipecat/services/openai/tts.py b/src/pipecat/services/openai/tts.py index 66f027c8d..a0e6a93dd 100644 --- a/src/pipecat/services/openai/tts.py +++ b/src/pipecat/services/openai/tts.py @@ -70,8 +70,8 @@ class OpenAITTSSettings(TTSSettings): speed: Voice speed control (0.25 to 4.0, default 1.0). """ - instructions: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - speed: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + instructions: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + speed: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) class OpenAITTSService(TTSService): diff --git a/src/pipecat/services/settings.py b/src/pipecat/services/settings.py index 62d6dfd50..b1f7539db 100644 --- a/src/pipecat/services/settings.py +++ b/src/pipecat/services/settings.py @@ -440,7 +440,7 @@ class TTSSettings(ServiceSettings): ``__init__`` methods do the same at construction time. """ - voice: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + voice: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) language: Language | str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) _aliases: ClassVar[dict[str, str]] = {"voice_id": "voice"} diff --git a/src/pipecat/services/speechmatics/stt.py b/src/pipecat/services/speechmatics/stt.py index 2597724bb..836a5668a 100644 --- a/src/pipecat/services/speechmatics/stt.py +++ b/src/pipecat/services/speechmatics/stt.py @@ -114,7 +114,7 @@ class SpeechmaticsSTTSettings(STTSettings): extra_params: Extra parameters for the STT engine. """ - domain: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + domain: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) turn_detection_mode: TurnDetectionMode | _NotGiven = field(default_factory=lambda: NOT_GIVEN) speaker_active_format: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) speaker_passive_format: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -125,18 +125,22 @@ class SpeechmaticsSTTSettings(STTSettings): additional_vocab: list[AdditionalVocabEntry] | _NotGiven = field( default_factory=lambda: NOT_GIVEN ) - operating_point: OperatingPoint | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - max_delay: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - end_of_utterance_silence_trigger: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - end_of_utterance_max_delay: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - punctuation_overrides: dict[str, Any] | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - include_partials: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - split_sentences: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - enable_diarization: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - speaker_sensitivity: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - max_speakers: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - prefer_current_speaker: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - extra_params: dict[str, Any] | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + operating_point: OperatingPoint | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + max_delay: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + end_of_utterance_silence_trigger: float | None | _NotGiven = field( + default_factory=lambda: NOT_GIVEN + ) + end_of_utterance_max_delay: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + punctuation_overrides: dict[str, Any] | None | _NotGiven = field( + default_factory=lambda: NOT_GIVEN + ) + include_partials: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + split_sentences: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + enable_diarization: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + speaker_sensitivity: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + max_speakers: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + prefer_current_speaker: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + extra_params: dict[str, Any] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) #: Fields that can be updated on a live connection via the Speechmatics #: diarization-config API — no reconnect needed. diff --git a/src/pipecat/services/ultravox/llm.py b/src/pipecat/services/ultravox/llm.py index c1cd8d750..967dc7886 100644 --- a/src/pipecat/services/ultravox/llm.py +++ b/src/pipecat/services/ultravox/llm.py @@ -67,7 +67,7 @@ class UltravoxRealtimeLLMSettings(LLMSettings): output_medium: The output medium for the model ("voice" or "text"). """ - output_medium: str | _NotGiven = field(default=NOT_GIVEN) + output_medium: str | None | _NotGiven = field(default=NOT_GIVEN) class AgentInputParams(BaseModel):