Skip to content

Commit d89a3b0

Browse files
committed
docs: import httpx lazily in the translation tool
httpx is only present through the optional translate group (the SDK itself depends on httpx2), so a top-level import broke every environment that loads the docs tooling without that group. Import it next to anthropic, where its errors are caught.
1 parent 66bc75f commit d89a3b0

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

scripts/docs/translations.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
from pathlib import Path
4242
from typing import Any, Literal, Protocol, cast, get_args
4343

44-
import httpx
4544
import markdown
4645
import yaml
4746
import zensical.config
@@ -611,14 +610,16 @@ def anthropic_translator() -> Translator:
611610
starts before that first reply has begun streaming writes it again instead;
612611
`command_translate` orders the work so that is rare, and nothing waits on it.
613612
614-
`anthropic` lives in the non-default `translate` dependency group, so it is
615-
imported here, by name: offline commands and type checking never need it.
613+
`anthropic` (and `httpx`, its transport, whose errors can escape it) lives in
614+
the non-default `translate` dependency group, so both are imported here, by
615+
name: offline commands and type checking never need them.
616616
617617
Raises:
618618
ConfigError: The `translate` dependency group is not installed, or no credentials are configured.
619619
"""
620620
try:
621621
sdk = importlib.import_module("anthropic")
622+
httpx = importlib.import_module("httpx")
622623
except ImportError as exc:
623624
raise ConfigError(
624625
"the anthropic package is not installed; run with `uv run --frozen --group translate`"

0 commit comments

Comments
 (0)