Skip to content

Commit 88b8371

Browse files
committed
Fix CI: widen control_task_factory return to Any
Previous Protocol-based typing went the wrong direction: a Protocol with send_task(**kwargs) was too loose for ControlTask.send_task (which has specific positional params) AND too tight to uniformly cover the test fakes (NoopControlTask only accepts **kwargs, FakeControlTask takes named positional params). Mypy rejected ControlTask itself as the default. Drop the Protocol; type the factory return as Any. The runtime collaborator is duck-typed — the dispatcher only invokes send_task(**named_kwargs) — and Any is what the DI seam is actually for.
1 parent 07e8d85 commit 88b8371

1 file changed

Lines changed: 4 additions & 13 deletions

File tree

lib/galaxy/managers/sse_dispatch.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from typing import (
1616
Any,
1717
Optional,
18-
Protocol,
1918
)
2019

2120
from cachetools import TTLCache
@@ -30,17 +29,6 @@
3029
from galaxy.web.statsd_client import VanillaGalaxyStatsdClient
3130
from galaxy.web_stack import ApplicationStack
3231

33-
34-
class ControlTaskLike(Protocol):
35-
"""Structural type for the dispatcher's control-task collaborator.
36-
37-
The dispatcher only calls ``send_task(**kwargs)``. Typed as a Protocol so
38-
tests can pass lightweight fakes (``FakeControlTask``, ``NoopControlTask``)
39-
without subclassing ``ControlTask``.
40-
"""
41-
42-
def send_task(self, **kwargs: Any) -> Any: ...
43-
4432
log = logging.getLogger(__name__)
4533

4634

@@ -68,7 +56,10 @@ def __init__(
6856
application_stack: ApplicationStack,
6957
statsd_client: Optional[VanillaGalaxyStatsdClient] = None,
7058
clock: Callable[[], float] = time.monotonic,
71-
control_task_factory: Callable[[GalaxyQueueWorker], ControlTaskLike] = ControlTask,
59+
# Factory return is typed ``Any`` so ``ControlTask`` itself and test-only
60+
# duck-typed doubles (FakeControlTask/BoomControlTask/NoopControlTask)
61+
# all satisfy the signature under mypy.
62+
control_task_factory: Callable[[GalaxyQueueWorker], Any] = ControlTask,
7263
queues_provider: Optional[Callable[[], list[Queue]]] = None,
7364
) -> None:
7465
self._queue_worker = queue_worker

0 commit comments

Comments
 (0)