Skip to content

Commit 5cc4e4b

Browse files
committed
refactor: improve workable types
1 parent 77120bd commit 5cc4e4b

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/mpyflow/library/workable/element.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from mpyflow.shared.interfaces.logger import SyncStdoutInterface
1212
from mpyflow.shared.interfaces.work import WorkInterface
1313
from multiprocessing import synchronize
14-
from typing import Any, final, AsyncIterator
14+
from typing import final, AsyncIterator
1515

1616

1717
@final
@@ -90,13 +90,13 @@ def __init__(
9090
self,
9191
ctx: multiprocessing.context.SpawnContext,
9292
work_instance: WorkInterface[IN, OT],
93-
io_instance: IOInterface[IN, Any],
93+
io_instance: IOInterface[IN],
9494
/,
9595
) -> None:
9696
super().__init__()
9797
self.__sync_out: SyncStdoutInterface | None = None
9898
self.__work_obj: WorkInterface[IN, OT] = work_instance
99-
self.__io_obj: IOInterface[IN, OT] = io_instance
99+
self.__io_obj: IOInterface[IN] = io_instance
100100
self.__io_progress: IOProgress = IOProgress(ctx)
101101
self.__thp: ThreadPoolExecutor | None = None
102102
self.__gl_lock = ctx.Condition()
@@ -170,7 +170,7 @@ async def workable_read(self) -> InputData[IN] | None:
170170
async with self.__as_lock.reader_async:
171171
return await self.__io_obj.read(self.thp)
172172

173-
async def workable_write(self, data: OT, /) -> bool:
173+
async def workable_write(self, data: IN, /) -> bool:
174174
if self.__io_progress.end_type.error == 1 or self.sync_out.error_occurred():
175175
raise WorkableEx("Workable error was set!")
176176
if not self.__io_obj.has_output():

src/mpyflow/library/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(
4747
self,
4848
name: str,
4949
workable_in: tuple[Workable[IN, OT], ...],
50-
workable_out: tuple[Workable[Any, OT], ...],
50+
workable_out: tuple[Workable[OT, Any], ...],
5151
hub: bool = False,
5252
/,
5353
) -> None:

src/mpyflow/shared/interfaces/io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Protocol
44

55

6-
class IOInterface[IN, OT](Protocol):
6+
class IOInterface[IN](Protocol):
77

88
def has_input(self) -> bool: ...
99

@@ -15,7 +15,7 @@ def on_error(self) -> None: ...
1515

1616
async def read(self, thread_pool: ThreadPoolExecutor, /) -> InputData[IN] | None: ...
1717

18-
async def write(self, data: OT, thread_pool: ThreadPoolExecutor, /) -> bool: ...
18+
async def write(self, data: IN, thread_pool: ThreadPoolExecutor, /) -> bool: ...
1919

2020
async def running(
2121
self, thread_pool: ThreadPoolExecutor, provider_cnt: int, /

0 commit comments

Comments
 (0)