Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions pyisolate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@

try:
from .checkpoint import checkpoint, restore
except Exception: # pragma: no cover - optional dependency
except (ModuleNotFoundError, ImportError) as exc: # pragma: no cover - optional dependency
# Trap only dependency-related import failures; let unrelated import-time
# bugs in optional modules propagate so they remain visible to developers.
if (
isinstance(exc, ModuleNotFoundError)
and exc.name
and exc.name.split(".", 1)[0] != "cryptography"
):
raise
if isinstance(exc, ImportError) and "cryptography" not in str(exc):
raise

def checkpoint(*args, **kwargs): # type: ignore[no-redef]
raise ModuleNotFoundError("cryptography is required for checkpoint support")
Expand Down Expand Up @@ -48,7 +58,17 @@ def restore(*args, **kwargs): # type: ignore[no-redef]

try:
from .migration import migrate
except Exception: # pragma: no cover - optional dependency
except (ModuleNotFoundError, ImportError) as exc: # pragma: no cover - optional dependency
# Trap only dependency-related import failures; let unrelated import-time
# bugs in optional modules propagate so they remain visible to developers.
if (
isinstance(exc, ModuleNotFoundError)
and exc.name
and exc.name.split(".", 1)[0] != "cryptography"
):
raise
if isinstance(exc, ImportError) and "cryptography" not in str(exc):
raise

def migrate(*args, **kwargs): # type: ignore[no-redef]
raise ModuleNotFoundError("cryptography is required for migration support")
Expand Down
Loading