Coverage for backend/idaes_service/solver/flowsheet_manager_type.py: 100%
2 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-06 23:27 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-06 23:27 +0000
1# Because there are a lot of things that reference the flowsheet manager, we
2# get a circular dependency.
3# But this is only a problem for the type hints.
4# so instead, we will use this trick:
6from typing import TYPE_CHECKING
7if TYPE_CHECKING:
8 from .flowsheet_manager import FlowsheetManager
9else:
10 FlowsheetManager = "FlowsheetManager"
11# This only imports the type if we are checking types.
12# Then as long as we use the type hints as a forward reference, we are okay.
13# https://peps.python.org/pep-0484/#forward-references
14# e.g
15# from .flowsheet_manager_type import FlowsheetManager
16# def __init__(self, flowsheet_manager: "FlowsheetManager"):
17# rather than
18# from .flowsheet_manager import FlowsheetManager
19# def __init__(self, flowsheet_manager: FlowsheetManager):
20#