hishel 1.1.6__py3-none-any.whl → 1.1.7__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/_async_cache.py CHANGED
@@ -197,12 +197,12 @@ class AsyncCacheProxy:
197
197
  return state.next(revalidation_response)
198
198
 
199
199
  async def _handle_update(self, state: NeedToBeUpdated) -> AnyState:
200
- for entry in state.updating_entries:
200
+ for updating_entry in state.updating_entries:
201
201
  await self.storage.update_entry(
202
- entry.id,
203
- lambda entry: replace(
204
- entry,
205
- response=replace(entry.response, headers=entry.response.headers),
202
+ updating_entry.id,
203
+ lambda existing_entry: replace(
204
+ existing_entry,
205
+ response=replace(existing_entry.response, headers=updating_entry.response.headers),
206
206
  ),
207
207
  )
208
208
  return state.next()
@@ -43,16 +43,12 @@ try:
43
43
  self,
44
44
  *,
45
45
  connection: Optional[anysqlite.Connection] = None,
46
- database_path: str = "hishel_cache.db",
46
+ database_path: Union[str, Path] = "hishel_cache.db",
47
47
  default_ttl: Optional[float] = None,
48
48
  refresh_ttl_on_access: bool = True,
49
49
  ) -> None:
50
- db_path = Path(database_path)
51
-
52
50
  self.connection = connection
53
- self.database_path = (
54
- ensure_cache_dict(db_path.parent if db_path.parent != Path(".") else None) / db_path.name
55
- )
51
+ self.database_path: Path = database_path if isinstance(database_path, Path) else Path(database_path)
56
52
  self.default_ttl = default_ttl
57
53
  self.refresh_ttl_on_access = refresh_ttl_on_access
58
54
  self.last_cleanup = time.time() - BATCH_CLEANUP_INTERVAL + BATCH_CLEANUP_START_DELAY
@@ -63,7 +59,10 @@ try:
63
59
  async def _ensure_connection(self) -> anysqlite.Connection:
64
60
  """Ensure connection is established and database is initialized."""
65
61
  if self.connection is None:
66
- self.connection = await anysqlite.connect(str(self.database_path))
62
+ # Create cache directory and resolve full path on first connection
63
+ parent = self.database_path.parent if self.database_path.parent != Path(".") else None
64
+ full_path = ensure_cache_dict(parent) / self.database_path.name
65
+ self.connection = await anysqlite.connect(str(full_path))
67
66
  if not self._initialized:
68
67
  await self._initialize_database()
69
68
  self._initialized = True
@@ -421,6 +420,7 @@ try:
421
420
  break
422
421
  yield chunk
423
422
  chunk_number += 1
423
+
424
424
  except ImportError:
425
425
 
426
426
  class AsyncSqliteStorage: # type: ignore[no-redef]
@@ -43,16 +43,12 @@ try:
43
43
  self,
44
44
  *,
45
45
  connection: Optional[sqlite3.Connection] = None,
46
- database_path: str = "hishel_cache.db",
46
+ database_path: Union[str, Path] = "hishel_cache.db",
47
47
  default_ttl: Optional[float] = None,
48
48
  refresh_ttl_on_access: bool = True,
49
49
  ) -> None:
50
- db_path = Path(database_path)
51
-
52
50
  self.connection = connection
53
- self.database_path = (
54
- ensure_cache_dict(db_path.parent if db_path.parent != Path(".") else None) / db_path.name
55
- )
51
+ self.database_path: Path = database_path if isinstance(database_path, Path) else Path(database_path)
56
52
  self.default_ttl = default_ttl
57
53
  self.refresh_ttl_on_access = refresh_ttl_on_access
58
54
  self.last_cleanup = time.time() - BATCH_CLEANUP_INTERVAL + BATCH_CLEANUP_START_DELAY
@@ -63,7 +59,10 @@ try:
63
59
  def _ensure_connection(self) -> sqlite3.Connection:
64
60
  """Ensure connection is established and database is initialized."""
65
61
  if self.connection is None:
66
- self.connection = sqlite3.connect(str(self.database_path))
62
+ # Create cache directory and resolve full path on first connection
63
+ parent = self.database_path.parent if self.database_path.parent != Path(".") else None
64
+ full_path = ensure_cache_dict(parent) / self.database_path.name
65
+ self.connection = sqlite3.connect(str(full_path))
67
66
  if not self._initialized:
68
67
  self._initialize_database()
69
68
  self._initialized = True
@@ -421,6 +420,7 @@ try:
421
420
  break
422
421
  yield chunk
423
422
  chunk_number += 1
423
+
424
424
  except ImportError:
425
425
 
426
426
  class SyncSqliteStorage: # type: ignore[no-redef]
hishel/_sync_cache.py CHANGED
@@ -197,12 +197,12 @@ class SyncCacheProxy:
197
197
  return state.next(revalidation_response)
198
198
 
199
199
  def _handle_update(self, state: NeedToBeUpdated) -> AnyState:
200
- for entry in state.updating_entries:
200
+ for updating_entry in state.updating_entries:
201
201
  self.storage.update_entry(
202
- entry.id,
203
- lambda entry: replace(
204
- entry,
205
- response=replace(entry.response, headers=entry.response.headers),
202
+ updating_entry.id,
203
+ lambda existing_entry: replace(
204
+ existing_entry,
205
+ response=replace(existing_entry.response, headers=updating_entry.response.headers),
206
206
  ),
207
207
  )
208
208
  return state.next()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hishel
3
- Version: 1.1.6
3
+ Version: 1.1.7
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,6 +406,32 @@ 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
+ ## What's Changed in 1.1.7
410
+ ### ♻️ Refactoring
411
+
412
+ * refactor(storage): create sqlite database path only when creating connections by @jeefberkey in [#426](https://github.com/karpetrosyan/hishel/pull/426)
413
+ ### ⚙️ Miscellaneous Tasks
414
+
415
+ * chore(deps-dev): bump the python-packages group with 5 updates by @dependabot[bot] in [#424](https://github.com/karpetrosyan/hishel/pull/424)
416
+ ### 🐛 Bug Fixes
417
+
418
+ * fix(cache): Lambda parameter name clashes the loop variable being closed over by @dump247 in [#427](https://github.com/karpetrosyan/hishel/pull/427)
419
+ ### 📚 Documentation
420
+
421
+ * add release process guidelines for maintainers by @karpetrosyan
422
+ ### 🚀 Features
423
+
424
+ * Feature/accept pathlib path in SqliteStorage by @daudef in [#419](https://github.com/karpetrosyan/hishel/pull/419)
425
+
426
+ ### Contributors
427
+ * @daudef
428
+ * @dependabot[bot]
429
+ * @jeefberkey
430
+ * @dump247
431
+ * @karpetrosyan
432
+
433
+ **Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.1.6...1.1.7
434
+
409
435
  ## What's Changed in 1.1.6
410
436
  ### 📚 Documentation
411
437
 
@@ -1,8 +1,8 @@
1
1
  hishel/__init__.py,sha256=1EdAEXWx41gmxUzG1Fchd_B4gQDtqlxlqQw0WkCBaUE,1826
2
- hishel/_async_cache.py,sha256=4wm6YBL9ClNOg4WbEkALTJVCIXuzQU80MVem2C3hHrQ,8785
2
+ hishel/_async_cache.py,sha256=QprSuucR6OXYWNVS9lzM1jHjUEC33AGq8zpUT27Cngs,8839
3
3
  hishel/_async_httpx.py,sha256=89i92f2SlvgWrav_TDNU1iUzMxdR607apauxXA3pE3U,8127
4
4
  hishel/_policies.py,sha256=1ae_rmDF7oaG91-lQyOGVaTrRX8uI2GImmu5gN6WJa4,1135
5
- hishel/_sync_cache.py,sha256=k0AN0M--yR4Jc6SiAreaxPUFiwEt5Dx7wi9jqW9sy50,8510
5
+ hishel/_sync_cache.py,sha256=afM1MfBlT3kitBJX-YmDEJ4i6Kc1d0A4PcrvCL6LlPI,8564
6
6
  hishel/_sync_httpx.py,sha256=z1pwVUQfRf72Q48PXXZ4FKwXGevll0X5iHcVRANiP38,7952
7
7
  hishel/_utils.py,sha256=kR7RnhFqLzFRmB-YNnZteQVP0iDPUouCscA0_FHHFls,3837
8
8
  hishel/asgi.py,sha256=ocXzqrrYGazeJxlKFcz1waoKvKGOqJ7YBEAmly4Towk,14998
@@ -14,11 +14,11 @@ hishel/_core/_headers.py,sha256=hGaT6o1F-gs1pm5RpdGb0IMQL3uJYDH1xpwJLy28Cys,1751
14
14
  hishel/_core/_spec.py,sha256=26mrK0MFSN_03ZecKem0asHYCXqzJ0tmcVmJXG7VHeI,105016
15
15
  hishel/_core/models.py,sha256=EabP2qnjYVzhPWhQer3QFmdDE6TDbqEBEqPHzv25VnA,7978
16
16
  hishel/_core/_storages/_async_base.py,sha256=iZ6Mb30P0ho5h4UU5bgOrcsSMZ1427j9tht-tupZs68,2106
17
- hishel/_core/_storages/_async_sqlite.py,sha256=IDMbtmbQ8e12HUlNJGyn6SIYColupuIbtvGfNl47_pM,15916
17
+ hishel/_core/_storages/_async_sqlite.py,sha256=3h1VEYGaiWdr-q3XT30MYPLBEN2R7g96BfUG5-hsRqM,16102
18
18
  hishel/_core/_storages/_packing.py,sha256=mC8LMFQ5uPfFOgingKm2WKFO_DwcZ1OjTgI6xc0hfJI,3708
19
19
  hishel/_core/_storages/_sync_base.py,sha256=qfOvcFY5qvrzSh4ztV2Trlxft-BF7An5SFsLlEb8EeE,2075
20
- hishel/_core/_storages/_sync_sqlite.py,sha256=MidCVhhzlf2bZQ2_UzZzh0r_14HGZpFEomkGU5POjuk,15385
21
- hishel-1.1.6.dist-info/METADATA,sha256=xQuRX_gSxX_sqXkwKnH7Mtsft7tUfym5L05CfbKeog4,20803
22
- hishel-1.1.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- hishel-1.1.6.dist-info/licenses/LICENSE,sha256=1qQj7pE0V2O9OIedvyOgLGLvZLaPd3nFEup3IBEOZjQ,1493
24
- hishel-1.1.6.dist-info/RECORD,,
20
+ hishel/_core/_storages/_sync_sqlite.py,sha256=t8OAVhydr56SDFditvhjpUwt_Nco4dAKEv7-bRPMPgM,15571
21
+ hishel-1.1.7.dist-info/METADATA,sha256=1crLOlKwSXnos2wCQ0fb0BWU42_hBR_unEcAGHLAX3c,21752
22
+ hishel-1.1.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ hishel-1.1.7.dist-info/licenses/LICENSE,sha256=1qQj7pE0V2O9OIedvyOgLGLvZLaPd3nFEup3IBEOZjQ,1493
24
+ hishel-1.1.7.dist-info/RECORD,,
File without changes