Create a ToolManager instance using factory or default constructor. This pattern allows tests to inject mock ToolManagers without dynamic getattr.
(
config_file: str,
servers: list[str],
server_names: dict[int, str | None] | None = None,
initialization_timeout: float = 120.0,
runtime_config: "RuntimeConfig | None" = None,
)
| 52 | |
| 53 | |
| 54 | def _create_tool_manager( |
| 55 | config_file: str, |
| 56 | servers: list[str], |
| 57 | server_names: dict[int, str | None] | None = None, |
| 58 | initialization_timeout: float = 120.0, |
| 59 | runtime_config: "RuntimeConfig | None" = None, |
| 60 | ) -> ToolManager: |
| 61 | """Create a ToolManager instance using factory or default constructor. |
| 62 | |
| 63 | This pattern allows tests to inject mock ToolManagers without dynamic getattr. |
| 64 | """ |
| 65 | if _tool_manager_factory is not None: |
| 66 | return _tool_manager_factory( |
| 67 | config_file, |
| 68 | servers, |
| 69 | server_names, |
| 70 | initialization_timeout=initialization_timeout, |
| 71 | runtime_config=runtime_config, |
| 72 | ) |
| 73 | return ToolManager( |
| 74 | config_file, |
| 75 | servers, |
| 76 | server_names, |
| 77 | initialization_timeout=initialization_timeout, |
| 78 | runtime_config=runtime_config, |
| 79 | ) |
| 80 | |
| 81 | |
| 82 | # --------------------------------------------------------------------------- # |