Modernize Python typing across the codebase

Automated via ruff UP006, UP007, UP035, UP045 rules (target: py311):

- Replace `typing.List`, `Dict`, `Tuple`, `Set`, `FrozenSet`, `Type`
  with their built-in equivalents (`list`, `dict`, `tuple`, etc.)
- Replace `typing.Optional[X]` with `X | None`
- Replace `typing.Union[X, Y]` with `X | Y`
- Move `Mapping`, `Sequence`, `Callable`, `Awaitable`,
  `MutableMapping`, `MutableSequence`, `Iterator`, `AsyncIterator`,
  `AsyncGenerator` imports from `typing` to `collections.abc`
- Remove now-unused `typing` imports
- Add `from __future__ import annotations` to 5 files that use
  forward-reference strings in `X | "Y"` annotations
This commit is contained in:
Aleix Conchillo Flaqué
2026-04-16 09:16:53 -07:00
parent 12b8af3d89
commit b3bb6fdaa5
283 changed files with 2902 additions and 3020 deletions

View File

@@ -6,7 +6,6 @@
import asyncio
import unittest
from typing import List
from pipecat.audio.vad.vad_analyzer import VADAnalyzer, VADParams, VADState
from pipecat.audio.vad.vad_controller import VADController
@@ -125,7 +124,7 @@ class TestVADController(unittest.IsolatedAsyncioTestCase):
analyzer = MockVADAnalyzer()
controller = VADController(analyzer)
pushed_frames: List[tuple] = []
pushed_frames: list[tuple] = []
@controller.event_handler("on_push_frame")
async def on_push_frame(_controller, frame: Frame, direction: FrameDirection):
@@ -143,7 +142,7 @@ class TestVADController(unittest.IsolatedAsyncioTestCase):
analyzer = MockVADAnalyzer()
controller = VADController(analyzer)
broadcast_calls: List[tuple] = []
broadcast_calls: list[tuple] = []
@controller.event_handler("on_broadcast_frame")
async def on_broadcast_frame(_controller, frame_cls, **kwargs):
@@ -192,7 +191,7 @@ class TestVADController(unittest.IsolatedAsyncioTestCase):
analyzer = MockVADAnalyzer()
controller = VADController(analyzer)
broadcast_calls: List[tuple] = []
broadcast_calls: list[tuple] = []
@controller.event_handler("on_broadcast_frame")
async def on_broadcast_frame(_controller, frame_cls, **kwargs):