Skip to content

Commit 92c7457

Browse files
committed
refactor: remove generic from process unit and system
It doesn't make sense with generic without an input of the generic type
1 parent 91f65b6 commit 92c7457

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed
+12-15
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1+
from __future__ import annotations
2+
13
import abc
2-
from typing import Generic, TypeVar
4+
from typing import Protocol, TypeVar
35
from uuid import UUID
46

57
ProcessUnitID = UUID
68

79

8-
class Stream(abc.ABC):
9-
@property
10-
@abc.abstractmethod
11-
def from_process_unit_id(self) -> ProcessUnitID | None: ...
12-
13-
@property
14-
@abc.abstractmethod
15-
def to_process_unit_id(self) -> ProcessUnitID | None: ...
10+
class Stream(Protocol):
11+
from_process_unit_id: ProcessUnitID | None
12+
to_process_unit_id: ProcessUnitID | None
1613

1714

18-
class MultiPhaseStream(Stream, abc.ABC):
15+
class MultiPhaseStream(Stream):
1916
"""
2017
Represents a fluid stream with multiple phases, liquid and gas.
2118
@@ -24,7 +21,7 @@ class MultiPhaseStream(Stream, abc.ABC):
2421
...
2522

2623

27-
class LiquidStream(Stream, abc.ABC):
24+
class LiquidStream(Stream):
2825
"""
2926
Represents a fluid stream with only a liquid phase.
3027
"""
@@ -35,7 +32,7 @@ class LiquidStream(Stream, abc.ABC):
3532
TStream = TypeVar("TStream", bound=LiquidStream | MultiPhaseStream)
3633

3734

38-
class ProcessUnit(abc.ABC, Generic[TStream]):
35+
class ProcessUnit(abc.ABC):
3936
@abc.abstractmethod
4037
def get_id(self) -> ProcessUnitID: ...
4138

@@ -46,9 +43,9 @@ def get_type(self) -> str: ...
4643
def get_name(self) -> str: ...
4744

4845
@abc.abstractmethod
49-
def get_streams(self) -> list[TStream]: ...
46+
def get_streams(self) -> list[LiquidStream] | list[MultiPhaseStream]: ...
5047

5148

52-
class ProcessSystem(ProcessUnit, abc.ABC, Generic[TStream]):
49+
class ProcessSystem(ProcessUnit, abc.ABC):
5350
@abc.abstractmethod
54-
def get_process_units(self) -> list["ProcessSystem[TStream]" | ProcessUnit[TStream]]: ...
51+
def get_process_units(self) -> list[ProcessSystem | ProcessUnit]: ...

0 commit comments

Comments
 (0)