mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
fix(hanzoai): 3.1.1 — guard optional ZAP import so import hanzoai works without the [zap] extra
zap.py is an httpx.BaseTransport; httpx is not a base dep (client core is urllib3). 3.1.0 imported zap.py eagerly in __init__, so `import hanzoai` crashed on missing httpx in any clean install. Guard the import (try/except ImportError) and declare httpx under the [zap] extra. import hanzoai now works with or without extras.
This commit is contained in:
+15
-10
@@ -18,16 +18,21 @@
|
||||
__version__ = "1.0.0"
|
||||
|
||||
|
||||
# Optional ZAP-native transport (opt-in). Imported lazily inside `zap` so that
|
||||
# `import hanzoai` still works when the optional `hanzo-zap` extra is not installed.
|
||||
# These names are additive and intentionally NOT part of the locked `__all__`.
|
||||
from . import zap as zap
|
||||
from .zap import (
|
||||
ZapTransport as ZapTransport,
|
||||
AsyncZapTransport as AsyncZapTransport,
|
||||
zap_http_client as zap_http_client,
|
||||
async_zap_http_client as async_zap_http_client,
|
||||
)
|
||||
# Optional ZAP-native transport (opt-in via the `zap` extra). The transport is an
|
||||
# httpx.BaseTransport, so `zap` requires httpx + hanzo-zap (neither is a base dep —
|
||||
# the client core is urllib3). Guard the import so `import hanzoai` still works when
|
||||
# the extra is absent; the names appear only when `pip install hanzoai[zap]` is used.
|
||||
# Additive and intentionally NOT part of the locked `__all__`.
|
||||
try:
|
||||
from . import zap as zap
|
||||
from .zap import (
|
||||
ZapTransport as ZapTransport,
|
||||
AsyncZapTransport as AsyncZapTransport,
|
||||
zap_http_client as zap_http_client,
|
||||
async_zap_http_client as async_zap_http_client,
|
||||
)
|
||||
except ImportError: # pragma: no cover - hanzoai[zap] not installed
|
||||
pass
|
||||
|
||||
# Define package exports
|
||||
__all__ = [
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "hanzoai"
|
||||
version = "3.1.0"
|
||||
version = "3.1.1"
|
||||
description = "The official Python library for the Hanzo API"
|
||||
dynamic = ["readme"]
|
||||
license = "BSD-3-Clause"
|
||||
@@ -34,7 +34,7 @@ classifiers = [
|
||||
llm = ["hanzo-llm>=1.0.0"]
|
||||
# Optional ZAP-native binary transport (hanzoai.zap). Off by default; opt in via
|
||||
# `hanzoai.zap_http_client(...)`. hanzo-zap pulls in zap-proto for the wire codec.
|
||||
zap = ["hanzo-zap>=0.7.0"]
|
||||
zap = ["hanzo-zap>=0.7.0", "httpx>=0.27.0"]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/hanzoai/python-sdk"
|
||||
|
||||
Reference in New Issue
Block a user