Skip to content

Commit 4b16ca7

Browse files
kraenhansenclaude
andcommitted
fix: use typing.List/Tuple for Python 3.8 compatibility
Replace PEP 585 lowercase generics (list[tuple[...]]) with typing.List[typing.Tuple[...]] to avoid TypeError on Python 3.8. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2163d22 commit 4b16ca7

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/elevenlabs/conversational_ai/conversation.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,22 +422,22 @@ def _get_wss_url(self):
422422
return self.on_prem_config.on_prem_conversation_url
423423

424424
base_http_url = self.client._client_wrapper.get_base_url()
425-
base_ws_url = (
426-
urllib.parse.urlparse(base_http_url)
427-
._replace(scheme="wss" if base_http_url.startswith("https") else "ws")
428-
.geturl()
425+
parsed = urllib.parse.urlparse(base_http_url)._replace(
426+
scheme="wss" if base_http_url.startswith("https") else "ws",
429427
)
430-
# Ensure base URL ends with '/' for proper joining
431-
if not base_ws_url.endswith("/"):
432-
base_ws_url += "/"
433-
params: list[tuple[str, str]] = [
428+
params = [
434429
("agent_id", self.agent_id),
435430
("source", "python_sdk"),
436431
("version", __version__),
437432
]
438433
if self.environment:
439434
params.append(("environment", self.environment))
440-
return f"{base_ws_url}v1/convai/conversation?{urllib.parse.urlencode(params)}"
435+
# Ensure base path ends with '/' so urljoin appends rather than replaces
436+
base_path = parsed.path if parsed.path.endswith("/") else parsed.path + "/"
437+
return urllib.parse.urlunparse(parsed._replace(
438+
path=base_path + "v1/convai/conversation",
439+
query=urllib.parse.urlencode(params),
440+
))
441441

442442
def _get_signed_url(self):
443443
response = self.client.conversational_ai.conversations.get_signed_url(

src/elevenlabs/realtime/scribe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,14 @@ def _build_websocket_url(
372372
base = self.base_url.replace("https://", "wss://").replace("http://", "ws://")
373373

374374
# Build query parameters
375-
params: list[tuple[str, str]] = [
375+
params = [
376376
("model_id", model_id),
377377
("audio_format", audio_format),
378378
("commit_strategy", commit_strategy),
379379
]
380380

381381
# Add optional parameters
382-
optional: list[tuple[str, typing.Any]] = [
382+
optional = [
383383
("vad_silence_threshold_secs", vad_silence_threshold_secs),
384384
("vad_threshold", vad_threshold),
385385
("min_speech_duration_ms", min_speech_duration_ms),

0 commit comments

Comments
 (0)