Skip to content

Commit 4242057

Browse files
committed
inherit the protocol or not?
1 parent f698369 commit 4242057

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/plumpy/coordinator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
from __future__ import annotations
33

44
from re import Pattern
5-
from typing import TYPE_CHECKING, Any, Callable, Hashable, Protocol
5+
from typing import TYPE_CHECKING, Any, Callable, Hashable, Protocol, runtime_checkable
66

77
if TYPE_CHECKING:
88
ID_TYPE = Hashable
99
Receiver = Callable[..., Any]
1010

1111

12+
@runtime_checkable
1213
class Coordinator(Protocol):
1314
def hook_rpc_receiver(
1415
self,

tests/rmq/test_coordinator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from plumpy.coordinator import Coordinator
2+
from . import RmqCoordinator
3+
4+
5+
def test_mock_coordinator():
6+
assert isinstance(RmqCoordinator, Coordinator)

tests/test_coordinator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from plumpy.coordinator import Coordinator
2+
from .utils import MockCoordinator
3+
4+
5+
def test_mock_coordinator():
6+
assert isinstance(MockCoordinator, Coordinator)

tests/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import plumpy
1515
from plumpy import persistence, process_states, processes, utils
16+
from plumpy.coordinator import Coordinator
1617
from plumpy.exceptions import CoordinatorConnectionError
1718
from plumpy.message import MessageBuilder
1819
from plumpy.rmq import TaskRejected
@@ -25,7 +26,7 @@
2526
Snapshot = collections.namedtuple('Snapshot', ['state', 'bundle', 'outputs'])
2627

2728

28-
class MockCoordinator:
29+
class MockCoordinator(Coordinator):
2930
def __init__(self):
3031
self._task_receivers = {}
3132
self._broadcast_receivers = {}

0 commit comments

Comments
 (0)