Skip to content

Commit 5c9da9b

Browse files
committed
Fix logo. Fix driver import fail formatting
1 parent 72773e8 commit 5c9da9b

File tree

5 files changed

+31
-8
lines changed

5 files changed

+31
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ assets/*
5454
!assets/favorites/
5555
assets/favorites/*
5656
!assets/favorites/logo.png
57+
!assets/favorites/logo_sqlit.png
5758
.worktrees/
5859
.obsidian/

assets/favorites/logo_sqlit.png

378 KB
Loading

sqlit/db/adapters/base.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
from __future__ import annotations
44

55
import importlib
6+
import os
67
from abc import ABC, abstractmethod
78
from dataclasses import dataclass
89
from pathlib import Path
910
from typing import TYPE_CHECKING, Any
1011

11-
from rich.markup import escape
12-
1312
if TYPE_CHECKING:
1413
from ...config import ConnectionConfig
1514

@@ -91,6 +90,18 @@ def import_driver_module(
9190
package_name: str | None,
9291
) -> Any:
9392
"""Import a driver module, raising MissingDriverError with detail if it fails."""
93+
# Mock flag to force driver import error for testing
94+
if os.environ.get("SQLIT_MOCK_DRIVER_ERROR") and extra_name and package_name:
95+
from ...db.exceptions import MissingDriverError
96+
97+
raise MissingDriverError(
98+
driver_name,
99+
extra_name,
100+
package_name,
101+
module_name=module_name,
102+
import_error=f"No module named '{module_name}'",
103+
)
104+
94105
if not extra_name or not package_name:
95106
return importlib.import_module(module_name)
96107

@@ -1039,9 +1050,7 @@ def _create_driver_import_error_hint(driver_name: str, extra_name: str, package_
10391050
from ...install_strategy import detect_strategy
10401051

10411052
strategy = detect_strategy(extra_name=extra_name, package_name=package_name)
1042-
instructions = escape(strategy.manual_instructions)
10431053
return (
10441054
f"{driver_name} driver not found.\n\n"
1045-
f"To connect to {driver_name}, run:\n\n"
1046-
f"[bold]{instructions}[/bold]\n"
1055+
f"{strategy.manual_instructions}\n"
10471056
)

sqlit/install_strategy.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _is_pipx() -> bool:
3737
pipx_override = os.environ.get("SQLIT_MOCK_PIPX", "").strip().lower()
3838
if pipx_override in {"1", "true", "yes", "pipx"}:
3939
return True
40-
if pipx_override in {"0", "false", "no", "pip", "unknown"}:
40+
if pipx_override in {"0", "false", "no", "pip", "unknown", "no-pip"}:
4141
return False
4242

4343
exe = sys.executable.lower()
@@ -70,6 +70,8 @@ def _pep668_externally_managed() -> bool:
7070

7171

7272
def _pip_available() -> bool:
73+
if os.environ.get("SQLIT_MOCK_PIPX", "").strip().lower() == "no-pip":
74+
return False
7375
return importlib.util.find_spec("pip") is not None
7476

7577

@@ -154,6 +156,18 @@ def _format_manual_instructions(package_name: str, reason: str) -> str:
154156

155157
def detect_strategy(*, extra_name: str, package_name: str) -> InstallStrategy:
156158
"""Detect the best installation strategy for optional driver dependencies."""
159+
# When mocking driver errors, also force the no-pip path to show full instructions
160+
if os.environ.get("SQLIT_MOCK_DRIVER_ERROR"):
161+
return InstallStrategy(
162+
kind="no-pip",
163+
can_auto_install=False,
164+
manual_instructions=_format_manual_instructions(
165+
package_name,
166+
"pip is not available for this Python interpreter.",
167+
),
168+
reason_unavailable="pip is not available.",
169+
)
170+
157171
if _is_unknown_install():
158172
return InstallStrategy(
159173
kind="unknown",

sqlit/ui/screens/package_setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from collections.abc import Callable
66

7-
from rich.markup import escape
87
from textual.app import ComposeResult
98
from textual.binding import Binding
109
from textual.containers import VerticalScroll
@@ -94,7 +93,7 @@ def compose(self) -> ComposeResult:
9493
)
9594

9695
with VerticalScroll(id="package-scroll"):
97-
yield Static(escape(self._instructions_text.strip()), id="package-script")
96+
yield Static(self._instructions_text.strip(), id="package-script")
9897

9998
def on_mount(self) -> None:
10099
self.query_one("#package-scroll", VerticalScroll).focus()

0 commit comments

Comments
 (0)