Skip to content

Feature: support hishel v2 - #340

Open
gigeresk wants to merge 5 commits into
yanyongyu:masterfrom
gigeresk:hishel-2.0
Open

gigeresk wants to merge 5 commits into
yanyongyu:masterfrom
gigeresk:hishel-2.0

Conversation

@gigeresk

@gigeresk gigeresk commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

#339 added a version lock to hishel<2.0 because hishel 2.0 was released today and this breaks githubkit installation. This PR attempts to update the source to reflect hishel's 2.0 API changes.

@yanyongyu yanyongyu added the enhancement New feature or request label Nov 6, 2026
@yanyongyu yanyongyu changed the title Fix breakages stemming from hishel 2.0 release Feature: support hishel v2 Nov 6, 2026
@yanyongyu

Copy link
Copy Markdown
Owner

I'd consider this a new feature adding support for hishel v2, rather than a githubkit installation fix.

@gigeresk

gigeresk commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author

@yanyongyu sure, the fix is here #339. All that to say, currently installation from pypi is broken.

uv run --isolated --no-project --with githubkit python -c "import githubkit; print('ok')"
# workaround:
uv run --isolated --no-project --with githubkit --with 'hishel<2' python -c "import githubkit; print('ok')"

@mgkvibez

mgkvibez commented Nov 6, 2026

Copy link
Copy Markdown

Reviewing this as a migration checklist, since I checked the new signature directly:

CacheTransport(next_transport, storage: BaseStorage | None = None, rfc: bool | CacheOptions = False)
AsyncCacheTransport(next_transport, storage: AsyncBaseStorage | None = None, rfc: bool | CacheOptions = False)

The CachePolicy → rfc/CacheOptions mapping and the SyncSqliteStorage → SqliteStorage rename both look right, and keeping AsyncBaseStorage in the annotation is correct, it still exists in 2.0.

One thing I would change before this lands:

The default flipped from None to True, which is not parity. Previously kwargs.pop("policy", None) meant "no policy"; now kwargs.pop("policy", True) goes into rfc, and rfc=True opts the transport into RFC-9111 heuristic freshness, so responses carrying validators can be served from cache where they previously would not have been. hishel's own default for rfc is False. If the intent is to preserve existing behaviour, False is the value matching the old None and hishel's default; if True is deliberate, it deserves a changelog line, because it silently changes caching for everyone who never passed policy.

Two smaller notes:

  1. The public kwarg keeps the name policy but changes type from CachePolicy | None to CacheOptions | bool. A caller passing a CachePolicy object now gets a TypeError at transport construction rather than something readable, so a line in the migration notes would save someone ten minutes.
  2. GitHub reports the PR as non-mergeable against master right now, most likely uv.lock. A rebase would let CI reflect the actual merge result.

If it is useful, I can test the caching path against a real conditional request, since the default question is the only part I cannot settle from the diff alone.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants