diff --git a/CHANGES.md b/CHANGES.md index af6ba8a..6a10fae 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ # About CrateDB changelog ## Unreleased +- Dependencies: Updated to Hishel 1.x ## v0.0.8 - 2025-07-28 - Outline: Shrank llms-txt output to <200_000 input tokens diff --git a/pyproject.toml b/pyproject.toml index 558f1b3..774ef6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,7 @@ dependencies = [ "cattrs[pyyaml]<26", "click<9", "colorlog<7", - "hishel<0.2", + "hishel[httpx]>=1,<1.2", "llms-txt==0.0.4", "markdown<4", "platformdirs<5", diff --git a/src/cratedb_about/util.py b/src/cratedb_about/util.py index c99a6be..ee03739 100644 --- a/src/cratedb_about/util.py +++ b/src/cratedb_about/util.py @@ -6,7 +6,7 @@ from collections import OrderedDict import attr -import hishel +import hishel.httpx from attrs import define from cattrs.preconf.json import make_converter as make_json_converter from cattrs.preconf.pyyaml import make_converter as make_yaml_converter @@ -64,16 +64,16 @@ def get_cache_client(ttl: t.Optional[t.Union[int, float]] = settings.http_cache_ Return the configured cache client. https://hishel.com/ """ - # Configure Hishel, a httpx client with caching. + # Configure Hishel, an httpx client with caching. logger.info(f"Configuring cache. ttl={ttl}, path={settings.http_cache_path}") try: - controller = hishel.Controller(allow_stale=True) - storage = hishel.SQLiteStorage( + storage = hishel.SyncSqliteStorage( connection=sqlite3.connect(settings.http_cache_path, check_same_thread=False), - ttl=ttl, + default_ttl=ttl, ) - return hishel.CacheClient( - controller=controller, storage=storage, timeout=settings.http_timeout + return hishel.httpx.SyncCacheClient( + storage=storage, + timeout=settings.http_timeout, ) except Exception as e: msg = ( diff --git a/tests/test_util.py b/tests/test_util.py index e0a39c9..d1761e7 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,4 +1,4 @@ -import hishel +import hishel.httpx import pytest from cratedb_about.util import get_cache_client @@ -6,14 +6,14 @@ def test_get_cache_client_valid(): client = get_cache_client() - assert isinstance(client, hishel.CacheClient) + assert isinstance(client, hishel.httpx.SyncCacheClient) def test_get_cache_client_failure(mocker, caplog): def _raise(*_args, **_kwargs): raise Exception("Test error") - mocker.patch.object(hishel.CacheClient, "__init__", _raise) + mocker.patch.object(hishel.httpx.SyncCacheClient, "__init__", _raise) with pytest.raises(Exception) as excinfo: get_cache_client() assert excinfo.match("Test error")