|
7 | 7 | import sys |
8 | 8 | from collections.abc import Callable |
9 | 9 | from pathlib import Path |
10 | | -from typing import TypeVar |
| 10 | +from typing import TYPE_CHECKING, TypeVar |
11 | 11 |
|
12 | 12 | import typer as _typer |
13 | 13 |
|
14 | | -from .client import DaemonStartError |
15 | | -from .protocol import DoctorCheckResult, IndexingProgress, ProjectStatusResponse, SearchResponse |
| 14 | +if TYPE_CHECKING: |
| 15 | + from .protocol import ( |
| 16 | + DoctorCheckResult, |
| 17 | + IndexingProgress, |
| 18 | + ProjectStatusResponse, |
| 19 | + SearchResponse, |
| 20 | + ) |
| 21 | + |
16 | 22 | from .settings import ( |
17 | 23 | DEFAULT_ST_MODEL, |
18 | 24 | EmbeddingSettings, |
@@ -104,6 +110,8 @@ def _catch_daemon_start_error(func: _F) -> _F: |
104 | 110 |
|
105 | 111 | @functools.wraps(func) |
106 | 112 | def wrapper(*args: object, **kwargs: object) -> object: |
| 113 | + from .client import DaemonStartError |
| 114 | + |
107 | 115 | try: |
108 | 116 | return func(*args, **kwargs) |
109 | 117 | except DaemonStartError as e: |
@@ -204,7 +212,7 @@ def _on_progress(progress: IndexingProgress) -> None: |
204 | 212 | except RuntimeError as e: |
205 | 213 | live.stop() |
206 | 214 | # Let DaemonStartError propagate to the decorator for consistent handling. |
207 | | - if isinstance(e, DaemonStartError): |
| 215 | + if isinstance(e, _client.DaemonStartError): |
208 | 216 | raise |
209 | 217 | _typer.echo(f"Indexing failed: {e}", err=True) |
210 | 218 | raise _typer.Exit(code=1) |
@@ -401,6 +409,7 @@ def _run_init_model_check(settings_path: Path) -> None: |
401 | 409 | from rich.spinner import Spinner as _Spinner |
402 | 410 |
|
403 | 411 | from . import client as _client |
| 412 | + from .protocol import DoctorCheckResult |
404 | 413 |
|
405 | 414 | err_console = _Console(stderr=True) |
406 | 415 | results: list[DoctorCheckResult] = [] |
|
0 commit comments