[Bugfix] Fix the remaining Python 3.10 breakages (#7985)

Signed-off-by: Armaan Amatya <armaanamatya2014@gmail.com>
Signed-off-by: Yueqian Lin <70319226+linyueqian@users.noreply.github.com>
Co-authored-by: Yueqian Lin <70319226+linyueqian@users.noreply.github.com>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
authored and GitHub committed 2026-09-30 11:38:23 +08:00
1 parent 989161c49d
commit aa41a3ac97
8 files changed
+51 -8

No files matched your search

@@ -470,9 +470,15 @@ class TestPipelineStreamingOutputToEntrypoint:
fixture: OrchestratorFixture,
inline_client: InlineStageDiffusionClient,
) -> None:
if omni.final_output_task is not None:
omni.final_output_task.cancel()
await asyncio.gather(omni.final_output_task, return_exceptions=True)
task = omni.final_output_task
omni.final_output_task = None
# The session ran inside ``TestClient``, whose loop is closed by the
# time the ``with`` block exits and the task with it already cancelled.
# Only a still-running task is worth cancelling and awaiting; gathering
# a finished one touches its closed loop on Python 3.10.
if task is not None and not task.done():
task.cancel()
await asyncio.gather(task, return_exceptions=True)
inline_client.shutdown()
fixture.request_sync_q.put_nowait(ShutdownRequestMessage())
await asyncio.to_thread(fixture.thread.join, 5)
@@ -451,3 +451,20 @@ def test_a_hint_survives_when_its_typed_field_is_unset():
command = AppendAudio(audio=b"\x00\x00" * 8, hints={"is_speech": True})
assert command.payload()["is_speech"] is True
def test_duplex_command_mixin_keeps_empty_slots():
"""The concrete commands combine ``DuplexCommand`` with a slotted wire command.
On Python 3.10 ``dataclass(slots=True)`` repeats the inherited fields in
``__slots__`` (fixed in 3.11), so a slotted ``DuplexCommand`` gives every
concrete command two slotted bases and the module does not import (#7475).
The mixin spells out empty slots instead; instances stay ``__dict__``-free
on every version.
"""
# ``__dataclass_params__`` only records ``slots`` from Python 3.12 on; an
# older interpreter proves the same thing by importing the module at all.
params = getattr(DuplexCommand, "__dataclass_params__")
assert getattr(params, "slots", False) is False, "slots=True on DuplexCommand breaks the import on Python 3.10"
assert DuplexCommand.__slots__ == ()
assert not hasattr(AppendAudio(audio=b"\x00\x00" * 8), "__dict__")
@@ -9,9 +9,13 @@ import types
from pathlib import Path
import pytest
import tomllib
from packaging.requirements import Requirement
try:
import tomllib
except ModuleNotFoundError: # Python < 3.11
import tomli as tomllib # type: ignore[no-redef]
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
ROOT = Path(__file__).parents[4]