1
+ from __future__ import annotations
2
+
1
3
import abc
2
- from typing import Generic , TypeVar
4
+ from typing import Protocol , TypeVar
3
5
from uuid import UUID
4
6
5
7
ProcessUnitID = UUID
6
8
7
9
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
16
13
17
14
18
- class MultiPhaseStream (Stream , abc . ABC ):
15
+ class MultiPhaseStream (Stream ):
19
16
"""
20
17
Represents a fluid stream with multiple phases, liquid and gas.
21
18
@@ -24,7 +21,7 @@ class MultiPhaseStream(Stream, abc.ABC):
24
21
...
25
22
26
23
27
- class LiquidStream (Stream , abc . ABC ):
24
+ class LiquidStream (Stream ):
28
25
"""
29
26
Represents a fluid stream with only a liquid phase.
30
27
"""
@@ -35,7 +32,7 @@ class LiquidStream(Stream, abc.ABC):
35
32
TStream = TypeVar ("TStream" , bound = LiquidStream | MultiPhaseStream )
36
33
37
34
38
- class ProcessUnit (abc .ABC , Generic [ TStream ] ):
35
+ class ProcessUnit (abc .ABC ):
39
36
@abc .abstractmethod
40
37
def get_id (self ) -> ProcessUnitID : ...
41
38
@@ -46,9 +43,9 @@ def get_type(self) -> str: ...
46
43
def get_name (self ) -> str : ...
47
44
48
45
@abc .abstractmethod
49
- def get_streams (self ) -> list [TStream ]: ...
46
+ def get_streams (self ) -> list [LiquidStream ] | list [ MultiPhaseStream ]: ...
50
47
51
48
52
- class ProcessSystem (ProcessUnit , abc .ABC , Generic [ TStream ] ):
49
+ class ProcessSystem (ProcessUnit , abc .ABC ):
53
50
@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