Skip to content

Commit 23f1be8

Browse files
committed
fix(sdk): narrow proto import suppression per review feedback
Replace broad contextlib.suppress with explicit error inspection. Proto/gRPC import failures are silently logged. Other ImportErrors surface as warnings so real issues aren't swallowed. Signed-off-by: Alexander Watson <zredlined@gmail.com>
1 parent 52fdded commit 23f1be8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

python/openshell/__init__.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66
from __future__ import annotations
77

8-
import contextlib
8+
import logging
9+
import warnings
910

10-
# Proto stubs may not be generated yet (requires Rust build).
11-
# Suppress so subpackages like openshell.prover can still be imported.
12-
with contextlib.suppress(ImportError):
11+
_log = logging.getLogger(__name__)
12+
13+
try:
1314
from .sandbox import ( # noqa: F401 — intentional re-exports
1415
ClusterInferenceConfig,
1516
ExecChunk,
@@ -22,6 +23,16 @@
2223
SandboxSession,
2324
TlsConfig,
2425
)
26+
except ImportError as _err:
27+
_msg = str(_err)
28+
if "proto" in _msg or "grpc" in _msg or "_pb2" in _msg:
29+
_log.debug("SDK symbols unavailable (proto stubs not generated): %s", _err)
30+
else:
31+
warnings.warn(
32+
f"openshell SDK symbols could not be imported: {_err}",
33+
ImportWarning,
34+
stacklevel=2,
35+
)
2536

2637
try:
2738
from importlib.metadata import version

0 commit comments

Comments
 (0)