hishel 1.1.1__py3-none-any.whl → 1.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
hishel/__init__.py CHANGED
@@ -27,7 +27,7 @@ from hishel._core.models import (
27
27
  from hishel._async_cache import AsyncCacheProxy as AsyncCacheProxy
28
28
  from hishel._sync_cache import SyncCacheProxy as SyncCacheProxy
29
29
 
30
- from hishel._policies import SpecificationPolicy, FilterPolicy, CachePolicy
30
+ from hishel._policies import SpecificationPolicy, FilterPolicy, CachePolicy, BaseFilter
31
31
 
32
32
  __all__ = (
33
33
  # New API
@@ -62,6 +62,7 @@ __all__ = (
62
62
  "AsyncCacheProxy",
63
63
  "SyncCacheProxy",
64
64
  # Policies
65
+ "BaseFilter",
65
66
  "CachePolicy",
66
67
  "SpecificationPolicy",
67
68
  "FilterPolicy",
hishel/_async_httpx.py CHANGED
@@ -174,6 +174,9 @@ class AsyncCacheTransport(httpx.AsyncBaseTransport):
174
174
  async def request_sender(self, request: Request) -> Response:
175
175
  httpx_request = _internal_to_httpx(request)
176
176
  httpx_response = await self.next_transport.handle_async_request(httpx_request)
177
+ if httpx_response.status_code == 304:
178
+ # 304 should not have a body, but we read it to ensure we'll not let the stream unconsumed
179
+ await httpx_response.aread()
177
180
  return _httpx_to_internal(httpx_response)
178
181
 
179
182
 
hishel/_core/_spec.py CHANGED
@@ -996,6 +996,7 @@ def exclude_unstorable_headers(response: Response, is_cache_shared: bool) -> Res
996
996
  def refresh_response_headers(
997
997
  stored_response: Response,
998
998
  revalidation_response: Response,
999
+ is_cache_shared: bool,
999
1000
  ) -> Response:
1000
1001
  """
1001
1002
  Updates a stored response's headers with fresh metadata from a 304 response.
@@ -1108,7 +1109,7 @@ def refresh_response_headers(
1108
1109
  stored_response,
1109
1110
  headers=Headers(new_headers),
1110
1111
  ),
1111
- is_cache_shared=True, # Assume shared cache for maximum safety
1112
+ is_cache_shared,
1112
1113
  )
1113
1114
 
1114
1115
 
@@ -1337,7 +1338,7 @@ class IdleClient(State):
1337
1338
  "A cache MUST NOT generate a stale response unless it is disconnected or
1338
1339
  doing so is explicitly permitted by the client or origin server."
1339
1340
  """
1340
- freshness_lifetime = get_freshness_lifetime(pair.response, is_cache_shared=True)
1341
+ freshness_lifetime = get_freshness_lifetime(pair.response, self.options.shared)
1341
1342
  age = get_age(pair.response)
1342
1343
 
1343
1344
  # Check freshness: response_is_fresh = (freshness_lifetime > current_age)
@@ -2245,7 +2246,7 @@ class NeedRevalidation(State):
2245
2246
  updating_entries=[
2246
2247
  replace(
2247
2248
  pair,
2248
- response=refresh_response_headers(pair.response, revalidation_response),
2249
+ response=refresh_response_headers(pair.response, revalidation_response, self.options.shared),
2249
2250
  )
2250
2251
  for pair in identified_for_revalidation
2251
2252
  ],
@@ -2409,4 +2410,4 @@ class NeedToBeUpdated(State):
2409
2410
  original_request: Request
2410
2411
 
2411
2412
  def next(self) -> FromCache:
2412
- return FromCache(entry=self.updating_entries[-1], options=self.options)
2413
+ return FromCache(entry=self.updating_entries[-1], options=self.options, after_revalidation=True)
hishel/_sync_httpx.py CHANGED
@@ -174,6 +174,9 @@ class SyncCacheTransport(httpx.BaseTransport):
174
174
  def request_sender(self, request: Request) -> Response:
175
175
  httpx_request = _internal_to_httpx(request)
176
176
  httpx_response = self.next_transport.handle_request(httpx_request)
177
+ if httpx_response.status_code == 304:
178
+ # 304 should not have a body, but we read it to ensure we'll not let the stream unconsumed
179
+ httpx_response.read()
177
180
  return _httpx_to_internal(httpx_response)
178
181
 
179
182
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hishel
3
- Version: 1.1.1
3
+ Version: 1.1.3
4
4
  Summary: Elegant HTTP Caching for Python
5
5
  Project-URL: Homepage, https://hishel.com
6
6
  Project-URL: Source, https://github.com/karpetrosyan/hishel
@@ -406,128 +406,220 @@ Hishel is inspired by and builds upon the excellent work in the Python HTTP ecos
406
406
  <strong>Made with ❤️ by <a href="https://github.com/karpetrosyan">Kar Petrosyan</a></strong>
407
407
  </p>
408
408
 
409
- # Changelog
409
+ ## What's Changed in 1.1.3
410
+ ### ⚙️ Miscellaneous Tasks
411
+
412
+ * improve git-cliff docs by @karpetrosyan
413
+ ### 🐛 Bug Fixes
414
+
415
+ * fix: add BaseFilter to __all__ exports by @martinblech in [#408](https://github.com/karpetrosyan/hishel/pull/408)
416
+ * fix: set `after_revalidation=True` for `NeedsToBeUpdated` -> `FromCache` transition by @jlopex in [#402](https://github.com/karpetrosyan/hishel/pull/402)
417
+
418
+ ### Contributors
419
+ * @martinblech
420
+ * @jlopex
421
+ * @karpetrosyan
422
+
423
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.1.2...1.1.3
424
+
425
+ ## What's Changed in 1.1.2
426
+ ### 🐛 Bug Fixes
427
+
428
+ * respect shared option when excluding unstorable headers by @karpetrosyan
429
+ * remove s-maxage consideration for private caches by @karpetrosyan
430
+ * ensure 304 responses don't leak by @karpetrosyan
431
+
432
+ ### Contributors
433
+ * @karpetrosyan
434
+ * @jlopex
410
435
 
411
- All notable changes to this project will be documented in this file.
436
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.1.1...1.1.2
412
437
 
413
- ## 1.1.1 - 2025-11-01
438
+ ## What's Changed in 1.1.1
414
439
  ### ⚙️ Miscellaneous Tasks
415
- - Bump the python-packages group with 10 updates (#396)
416
440
 
441
+ * chore(deps-dev): bump the python-packages group with 10 updates by @dependabot[bot] in [#396](https://github.com/karpetrosyan/hishel/pull/396)
417
442
  ### 📦 Dependencies
418
- - Bump actions/upload-artifact from 4 to 5 (#395)
419
- - Bump actions/download-artifact from 4 to 6 (#394)
420
- - Bump astral-sh/setup-uv from 5 to 7 (#393)
421
443
 
422
- ## 1.1.0 - 2025-10-31
444
+ * chore(deps): bump astral-sh/setup-uv from 5 to 7 by @dependabot[bot] in [#393](https://github.com/karpetrosyan/hishel/pull/393)
445
+ * chore(deps): bump actions/download-artifact from 4 to 6 by @dependabot[bot] in [#394](https://github.com/karpetrosyan/hishel/pull/394)
446
+ * chore(deps): bump actions/upload-artifact from 4 to 5 by @dependabot[bot] in [#395](https://github.com/karpetrosyan/hishel/pull/395)
447
+
448
+ ### Contributors
449
+ * @karpetrosyan
450
+ * @dependabot[bot]
451
+
452
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.1.0...1.1.1
453
+
454
+ ## What's Changed in 1.1.0
423
455
  ### ⚙️ Miscellaneous Tasks
424
- - Add in memory example
425
456
 
457
+ * add in memory example by @karpetrosyan
426
458
  ### 🐛 Bug Fixes
427
- - Pass any response with non-expected status code on revalidation to client
428
- - Pass any response with non-expected status code on revalidation to client
429
459
 
460
+ * pass any response with non-expected status code on revalidation to client by @karpetrosyan
461
+ * pass any response with non-expected status code on revalidation to client by @karpetrosyan
430
462
  ### 🚀 Features
431
- - Allow setting storage base with via `database_path` for sqlite storage
432
463
 
433
- ## 1.0.0 - 2025-10-28
464
+ * allow setting storage base with via `database_path` for sqlite storage by @karpetrosyan
465
+
466
+ ### Contributors
467
+ * @karpetrosyan
468
+
469
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.0.0...1.1.0
470
+
471
+ ## What's Changed in 1.0.0
434
472
  ### ⚙️ Miscellaneous Tasks
435
- - Add examples, improve docs
436
473
 
437
- ## 1.0.0b1 - 2025-10-28
474
+ * add examples, improve docs by @karpetrosyan
475
+
476
+ ### Contributors
477
+ * @karpetrosyan
478
+
479
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.0.0b1...1.0.0
480
+
481
+ ## What's Changed in 1.0.0b1
438
482
  ### ♻️ Refactoring
439
- - Add policies
440
483
 
484
+ * add policies by @karpetrosyan
441
485
  ### ⚙️ Miscellaneous Tasks
442
- - Improve sans-io diagram colors
443
- - Add graphql docs
444
486
 
487
+ * add graphql docs by @karpetrosyan
488
+ * improve sans-io diagram colors by @karpetrosyan
445
489
  ### 🐛 Bug Fixes
446
- - Body-sensitive responses caching
447
- - Filter out `Transfer-Encoding` header for asgi responses
448
490
 
491
+ * filter out `Transfer-Encoding` header for asgi responses by @karpetrosyan
492
+ * body-sensitive responses caching by @karpetrosyan
449
493
  ### 🚀 Features
450
- - Add global `use_body_key` setting
451
494
 
452
- ## 1.0.0.dev3 - 2025-10-26
495
+ * add global `use_body_key` setting by @karpetrosyan
496
+
497
+ ### Contributors
498
+ * @karpetrosyan
499
+
500
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.0.0.dev3...1.0.0b1
501
+
502
+ ## What's Changed in 1.0.0.dev3
453
503
  ### ♻️ Refactoring
454
- - Replace pairs with entries, simplify storage API
455
- - Automatically generate httpx sync integration from async
456
504
 
505
+ * automatically generate httpx sync integration from async by @karpetrosyan
506
+ * replace pairs with entries, simplify storage API by @karpetrosyan
457
507
  ### ⚙️ Miscellaneous Tasks
458
- - Simplify metadata docs
459
- - Add custom integrations docs
460
- - More robust compressed response caching
461
508
 
509
+ * more robust compressed response caching by @karpetrosyan
510
+ * add custom integrations docs by @karpetrosyan
511
+ * simplify metadata docs by @karpetrosyan
462
512
  ### 🐛 Bug Fixes
463
- - Add missing permissions into `publish.yml`
464
- - Raise on consumed httpx streams, which we can't store as is (it's already decoded)
465
- - Fix compressed data caching for requests
466
- - Handle httpx iterable usage instead of iterator correctly
467
- - Add date header for proper age calculation
468
513
 
514
+ * add date header for proper age calculation by @karpetrosyan
515
+ * handle httpx iterable usage instead of iterator correctly by @karpetrosyan
516
+ * fix compressed data caching for requests by @karpetrosyan
517
+ * raise on consumed httpx streams, which we can't store as is (it's already decoded) by @karpetrosyan
518
+ * add missing permissions into `publish.yml` by @karpetrosyan
469
519
  ### 🚀 Features
470
- - Add integrations with fastapi and asgi
471
- - Add blacksheep integration examples
472
- - Add logging for asgi
473
520
 
474
- ## 1.0.0.dev2 - 2025-10-21
521
+ * add logging for asgi by @karpetrosyan
522
+ * add blacksheep integration examples by @karpetrosyan
523
+ * add integrations with fastapi and asgi by @karpetrosyan
524
+
525
+ ### Contributors
526
+ * @karpetrosyan
527
+
528
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.0.0.dev2...1.0.0.dev3
529
+
530
+ ## What's Changed in 1.0.0.dev2
475
531
  ### ⚙️ Miscellaneous Tasks
476
- - Remove redundant utils and tests
477
- - Add import without extras check in ci
478
- - Fix time travel date, explicitly specify the timezone
479
532
 
533
+ * fix time travel date, explicitly specify the timezone by @karpetrosyan
534
+ * add import without extras check in ci by @karpetrosyan
535
+ * remove redundant utils and tests by @karpetrosyan
480
536
  ### 🐛 Bug Fixes
481
- - Fix check for storing auth requests
482
- - Don't raise an error on 3xx during revalidation
483
537
 
538
+ * don't raise an error on 3xx during revalidation by @karpetrosyan
539
+ * fix check for storing auth requests by @karpetrosyan
484
540
  ### 🚀 Features
485
- - Add hishel_created_at response metadata
486
541
 
487
- ## 1.0.0.dev1 - 2025-10-21
542
+ * add hishel_created_at response metadata by @karpetrosyan
543
+
544
+ ### Contributors
545
+ * @karpetrosyan
546
+
547
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.0.0.dev1...1.0.0.dev2
548
+
549
+ ## What's Changed in 1.0.0.dev1
488
550
  ### ⚙️ Miscellaneous Tasks
489
- - Remove some redundant utils methods
490
551
 
552
+ * remove some redundant utils methods by @karpetrosyan
491
553
  ### 📦 Dependencies
492
- - Make httpx and async libs optional dependencies
493
- - Make `anysqlite` optional dependency
494
- - Install async extra with httpx
495
- - Improve git-cliff
496
554
 
497
- ## 1.0.0.dev0 - 2025-10-19
555
+ * improve git-cliff by @karpetrosyan
556
+ * install async extra with httpx by @karpetrosyan
557
+ * make `anysqlite` optional dependency by @karpetrosyan
558
+ * make httpx and async libs optional dependencies by @karpetrosyan
559
+
560
+ ### Contributors
561
+ * @karpetrosyan
562
+
563
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.0.0.dev0...1.0.0.dev1
564
+
565
+ ## What's Changed in 1.0.0.dev0
498
566
  ### ⚙️ Miscellaneous Tasks
499
- - Use mike powered versioning
500
- - Improve docs versioning, deploy dev doc on ci
501
567
 
502
- ## 0.1.5 - 2025-10-18
568
+ * improve docs versioning, deploy dev doc on ci by @karpetrosyan
569
+ * use mike powered versioning by @karpetrosyan
570
+
571
+ ### Contributors
572
+ * @karpetrosyan
573
+
574
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/0.1.5...1.0.0.dev0
575
+
576
+ ## What's Changed in 0.1.5
503
577
  ### ⚙️ Miscellaneous Tasks
504
- - Remove some redundant files from repo
505
578
 
579
+ * remove some redundant files from repo by @karpetrosyan
506
580
  ### 🐛 Bug Fixes
507
- - Fix some line breaks
508
581
 
582
+ * fix some line breaks by @karpetrosyan
509
583
  ### 🚀 Features
510
- - Set chunk size to 128KB for httpx to reduce SQLite read/writes
511
- - Better cache-control parsing
512
- - Add close method to storages API (#384)
513
- - Increase requests buffer size to 128KB, disable charset detection
514
584
 
515
- ## 0.1.4 - 2025-10-14
585
+ * increase requests buffer size to 128KB, disable charset detection by @karpetrosyan
586
+ * feat: add close method to storages API by @karpetrosyan in [#384](https://github.com/karpetrosyan/hishel/pull/384)
587
+ * better cache-control parsing by @karpetrosyan
588
+ * set chunk size to 128KB for httpx to reduce SQLite read/writes by @karpetrosyan
589
+
590
+ ### Contributors
591
+ * @karpetrosyan
592
+
593
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/0.1.4...0.1.5
594
+
595
+ ## What's Changed in 0.1.4
516
596
  ### ⚙️ Miscellaneous Tasks
517
- - Improve CI (#369)
518
- - Remove src folder (#373)
519
- - Temporary remove python3.14 from CI
520
- - Add sqlite tests for new storage
521
- - Move some tests to beta
522
597
 
598
+ * move some tests to beta by @karpetrosyan
599
+ * add sqlite tests for new storage by @karpetrosyan
600
+ * temporary remove python3.14 from CI by @karpetrosyan
601
+ * chore(internal): remove src folder by @karpetrosyan in [#373](https://github.com/karpetrosyan/hishel/pull/373)
602
+ * chore: improve CI by @karpetrosyan in [#369](https://github.com/karpetrosyan/hishel/pull/369)
523
603
  ### 🐛 Bug Fixes
524
- - Create an sqlite file in a cache folder
525
- - Fix beta imports
526
604
 
605
+ * fix beta imports by @karpetrosyan
606
+ * create an sqlite file in a cache folder by @karpetrosyan
527
607
  ### 🚀 Features
528
- - Add support for a sans-IO API (#366)
529
- - Allow already consumed streams with `CacheTransport` (#377)
530
- - Add sqlite storage for beta storages
531
- - Get rid of some locks from sqlite storage
532
- - Better async implemetation for sqlite storage
608
+
609
+ * better async implemetation for sqlite storage by @karpetrosyan
610
+ * get rid of some locks from sqlite storage by @karpetrosyan
611
+ * add sqlite storage for beta storages by @karpetrosyan
612
+ * feat: allow already consumed streams with `CacheTransport` by @jamesbraza in [#377](https://github.com/karpetrosyan/hishel/pull/377)
613
+ * feat: add support for a sans-IO API by @karpetrosyan in [#366](https://github.com/karpetrosyan/hishel/pull/366)
614
+
615
+ ### Contributors
616
+ * @karpetrosyan
617
+ * @jamesbraza
618
+ * @GugNersesyan
619
+ * @dependabot[bot]
620
+ * @mmdbalkhi
621
+ * @AstraLuma
622
+ * @deathaxe
623
+
624
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/0.1.3...0.1.4
533
625
 
@@ -1,9 +1,9 @@
1
- hishel/__init__.py,sha256=XYnAlT2Wkrg0Cw5u4DLJAsC3TjWDOQJr5kqQMuXxEJI,1796
1
+ hishel/__init__.py,sha256=1EdAEXWx41gmxUzG1Fchd_B4gQDtqlxlqQw0WkCBaUE,1826
2
2
  hishel/_async_cache.py,sha256=4wm6YBL9ClNOg4WbEkALTJVCIXuzQU80MVem2C3hHrQ,8785
3
- hishel/_async_httpx.py,sha256=WB35o7CseRDz89dpqoWNLXYEkDxqeSo709eR3oPXP7Q,7536
3
+ hishel/_async_httpx.py,sha256=_-M5BEIyhrPiWJYy-zX0XbAvGFY6NLDdKtfiLt6Io6c,7726
4
4
  hishel/_policies.py,sha256=1ae_rmDF7oaG91-lQyOGVaTrRX8uI2GImmu5gN6WJa4,1135
5
5
  hishel/_sync_cache.py,sha256=k0AN0M--yR4Jc6SiAreaxPUFiwEt5Dx7wi9jqW9sy50,8510
6
- hishel/_sync_httpx.py,sha256=FbnJrdoLftPDVNUzYkAtz-JOTNtiBPJ2c1ZOcU0JnmE,7368
6
+ hishel/_sync_httpx.py,sha256=0wVXeapkFqWtsLq1xtlTpvL-TQ5T6HUyQ7RK4Kz0GMA,7551
7
7
  hishel/_utils.py,sha256=kR7RnhFqLzFRmB-YNnZteQVP0iDPUouCscA0_FHHFls,3837
8
8
  hishel/asgi.py,sha256=ocXzqrrYGazeJxlKFcz1waoKvKGOqJ7YBEAmly4Towk,14998
9
9
  hishel/fastapi.py,sha256=CVWCyXTxBPwG_XALo-Oldekv4lqMgH2-W-PPZ9rZjXg,10826
@@ -11,14 +11,14 @@ hishel/httpx.py,sha256=99a8X9COPiPHSgGW61O2uMWMZB7dY93Ty9DTCJ9C18Q,467
11
11
  hishel/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  hishel/requests.py,sha256=FbOBMvgNSWkH0Bh0qZdr-dhCYG6siR5Lmxcu5eMay3s,6409
13
13
  hishel/_core/_headers.py,sha256=hGaT6o1F-gs1pm5RpdGb0IMQL3uJYDH1xpwJLy28Cys,17514
14
- hishel/_core/_spec.py,sha256=YfZfMYS4--o0v-AQZ37vVzHfc-Mh-SEHcl9SrBM9Y7Y,102963
14
+ hishel/_core/_spec.py,sha256=5VLwyT-eSdbez87A6xJG8T_Z3ySVcEEQp8WyTY_mhCo,102988
15
15
  hishel/_core/models.py,sha256=EabP2qnjYVzhPWhQer3QFmdDE6TDbqEBEqPHzv25VnA,7978
16
16
  hishel/_core/_storages/_async_base.py,sha256=iZ6Mb30P0ho5h4UU5bgOrcsSMZ1427j9tht-tupZs68,2106
17
17
  hishel/_core/_storages/_async_sqlite.py,sha256=QZEWroGZKGhCMf7CcYpZfKZdKd88R8elQCoPge0Khxc,15674
18
18
  hishel/_core/_storages/_packing.py,sha256=mC8LMFQ5uPfFOgingKm2WKFO_DwcZ1OjTgI6xc0hfJI,3708
19
19
  hishel/_core/_storages/_sync_base.py,sha256=qfOvcFY5qvrzSh4ztV2Trlxft-BF7An5SFsLlEb8EeE,2075
20
20
  hishel/_core/_storages/_sync_sqlite.py,sha256=P3vIp636tTtM553-sBTZkam3-sNv0EEkh1rRSd1Qw90,15167
21
- hishel-1.1.1.dist-info/METADATA,sha256=-asM9uMqOksQJV8PucbLYqdeY5MPMz54d0bGwAsCs6E,16115
22
- hishel-1.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- hishel-1.1.1.dist-info/licenses/LICENSE,sha256=1qQj7pE0V2O9OIedvyOgLGLvZLaPd3nFEup3IBEOZjQ,1493
24
- hishel-1.1.1.dist-info/RECORD,,
21
+ hishel-1.1.3.dist-info/METADATA,sha256=wnTvK34erjBZbe20gkt-19WumeD2OFsURe9pSQfGcuk,19884
22
+ hishel-1.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ hishel-1.1.3.dist-info/licenses/LICENSE,sha256=1qQj7pE0V2O9OIedvyOgLGLvZLaPd3nFEup3IBEOZjQ,1493
24
+ hishel-1.1.3.dist-info/RECORD,,
File without changes