hishel 0.0.30__py3-none-any.whl → 0.0.31__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
@@ -14,4 +14,4 @@ def install_cache() -> None: # pragma: no cover
14
14
  httpx.Client = CacheClient # type: ignore
15
15
 
16
16
 
17
- __version__ = "0.0.30"
17
+ __version__ = "0.0.31"
@@ -227,10 +227,13 @@ class AsyncFileStorage(AsyncBaseStorage):
227
227
  async with self._lock:
228
228
  with os.scandir(self._base_path) as entries:
229
229
  for entry in entries:
230
- if entry.is_file():
231
- age = time.time() - entry.stat().st_mtime
232
- if age > self._ttl:
233
- os.unlink(entry.path)
230
+ try:
231
+ if entry.is_file():
232
+ age = time.time() - entry.stat().st_mtime
233
+ if age > self._ttl:
234
+ os.unlink(entry.path)
235
+ except FileNotFoundError: # pragma: no cover
236
+ pass
234
237
 
235
238
 
236
239
  class AsyncSQLiteStorage(AsyncBaseStorage):
@@ -374,8 +377,8 @@ class AsyncSQLiteStorage(AsyncBaseStorage):
374
377
  return self._serializer.loads(cached_response)
375
378
 
376
379
  async def aclose(self) -> None: # pragma: no cover
377
- assert self._connection
378
- await self._connection.close()
380
+ if self._connection is not None:
381
+ await self._connection.close()
379
382
 
380
383
  async def _remove_expired_caches(self) -> None:
381
384
  assert self._connection
hishel/_controller.py CHANGED
@@ -149,9 +149,6 @@ class Controller:
149
149
  method = request.method.decode("ascii")
150
150
  force_cache = request.extensions.get("force_cache", None)
151
151
 
152
- if force_cache if force_cache is not None else self._force_cache:
153
- return True
154
-
155
152
  if response.status not in self._cacheable_status_codes:
156
153
  return False
157
154
 
@@ -162,6 +159,9 @@ class Controller:
162
159
  if method not in self._cacheable_methods:
163
160
  return False
164
161
 
162
+ if force_cache if force_cache is not None else self._force_cache:
163
+ return True
164
+
165
165
  response_cache_control = parse_cache_control(extract_header_values_decoded(response.headers, b"cache-control"))
166
166
  request_cache_control = parse_cache_control(extract_header_values_decoded(request.headers, b"cache-control"))
167
167
 
hishel/_sync/_storages.py CHANGED
@@ -227,10 +227,13 @@ class FileStorage(BaseStorage):
227
227
  with self._lock:
228
228
  with os.scandir(self._base_path) as entries:
229
229
  for entry in entries:
230
- if entry.is_file():
231
- age = time.time() - entry.stat().st_mtime
232
- if age > self._ttl:
233
- os.unlink(entry.path)
230
+ try:
231
+ if entry.is_file():
232
+ age = time.time() - entry.stat().st_mtime
233
+ if age > self._ttl:
234
+ os.unlink(entry.path)
235
+ except FileNotFoundError: # pragma: no cover
236
+ pass
234
237
 
235
238
 
236
239
  class SQLiteStorage(BaseStorage):
@@ -374,8 +377,8 @@ class SQLiteStorage(BaseStorage):
374
377
  return self._serializer.loads(cached_response)
375
378
 
376
379
  def close(self) -> None: # pragma: no cover
377
- assert self._connection
378
- self._connection.close()
380
+ if self._connection is not None:
381
+ self._connection.close()
379
382
 
380
383
  def _remove_expired_caches(self) -> None:
381
384
  assert self._connection
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hishel
3
- Version: 0.0.30
3
+ Version: 0.0.31
4
4
  Summary: Persistent cache implementation for httpx and httpcore
5
5
  Project-URL: Homepage, https://hishel.com
6
6
  Project-URL: Source, https://github.com/karpetrosyan/hishel
@@ -175,6 +175,12 @@ Help us grow and continue developing good software for you ❤️
175
175
 
176
176
  # Changelog
177
177
 
178
+ ## 0.0.31 (22nd Sep, 2024)
179
+
180
+ - Ignore file not found error when cleaning up a file storage. (#264)
181
+ - Fix `AssertionError` on `client.close()` when use SQLiteStorage. (#269)
182
+ - Fix ignored flags when use `force_cache`. (#271)
183
+
178
184
  ## 0.0.30 (12th July, 2024)
179
185
 
180
186
  - Fix cache update on revalidation response with content (rfc9111 section 4.3.3) (#239)
@@ -1,5 +1,5 @@
1
- hishel/__init__.py,sha256=vDMrMrHiyMMr2z2_oc3HOjU8ZKDKx5t0b-U9lfo-IBg,369
2
- hishel/_controller.py,sha256=W5ad2herTHmMQ9dkUe6kcfc_AIpBID3CtwW1xh2aTpc,15875
1
+ hishel/__init__.py,sha256=XNbMtsi4tkqZZ6AgwVBDu6BumB6WkK3alKCqk-JVDWs,369
2
+ hishel/_controller.py,sha256=kfWAAtgP4RCYNPH33XeDJRJ-zajqS_w0ZbM0M0CsKiY,15875
3
3
  hishel/_exceptions.py,sha256=qbg55RNlzwhv5JreWY9Zog_zmmiKdn5degtqJKijuRs,198
4
4
  hishel/_files.py,sha256=7J5uX7Nnzd7QQWfYuDGh8v6XGLG3eUDBjoJZ4aTaY1c,2228
5
5
  hishel/_headers.py,sha256=TWuHi7sRoeS2xxdNGujKmqWtgncUqfhNGCgHKYpRU-I,7329
@@ -13,15 +13,15 @@ hishel/_async/__init__.py,sha256=_oAltH4emAtUF7_9SSxz_KKGYzSXL34o_EGgGvoPG7E,187
13
13
  hishel/_async/_client.py,sha256=AkVSSbNTTHmK0gX6PRYVQ-3aDbuCX2Im4VKbLkwLiBU,1101
14
14
  hishel/_async/_mock.py,sha256=995v9p5xiw3svGSOJATkLMqwodlhZhcwmGygLHM2VFw,1515
15
15
  hishel/_async/_pool.py,sha256=li-921qyGzrV7SVUOUlMI0KE7IRsupSkE5iApzxmgqk,8175
16
- hishel/_async/_storages.py,sha256=1VAuUaXGFPzYEuj0LgR644k1V0w3pgqVeCAvEhGA8Y8,28550
16
+ hishel/_async/_storages.py,sha256=SPWifKGSGAFP2wMFoxZf5weZFbuVgHFciyglY6Hb6fc,28699
17
17
  hishel/_async/_transports.py,sha256=moeH-eQLJHkMp83NnScgsQTSQntDCR1_4A1ByZ_fXjk,11174
18
18
  hishel/_sync/__init__.py,sha256=_oAltH4emAtUF7_9SSxz_KKGYzSXL34o_EGgGvoPG7E,187
19
19
  hishel/_sync/_client.py,sha256=O-gwm9DsveKtSFUfqdbBB-3I1FmXr5rE-uQ7X5frwDA,1060
20
20
  hishel/_sync/_mock.py,sha256=im88tZr-XhP9BpzvIt3uOjndAlNcJvFP7Puv3H-6lKU,1430
21
21
  hishel/_sync/_pool.py,sha256=VcAknzyAL2i4-zcyE2fOTmTjfBZ2wkBVNYTvSw0OjVQ,7940
22
- hishel/_sync/_storages.py,sha256=NCV5kaQ4z-4L0TKS7HEpWSPHdf5NLytmFB04TMPXnc0,27760
22
+ hishel/_sync/_storages.py,sha256=RYzYXqnv0o2JO3RoEmlEUp0yOg_ungXfz4dLN7UTpIQ,27909
23
23
  hishel/_sync/_transports.py,sha256=G3_8SdPwlnrHZRvE1gqFLE4oZadVqNgg5mvxghDMih0,10838
24
- hishel-0.0.30.dist-info/METADATA,sha256=ec6bxYRQ1Ona8399QWoiGr1rimdCLhH8CfzEPqolwP0,11248
25
- hishel-0.0.30.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
26
- hishel-0.0.30.dist-info/licenses/LICENSE,sha256=1qQj7pE0V2O9OIedvyOgLGLvZLaPd3nFEup3IBEOZjQ,1493
27
- hishel-0.0.30.dist-info/RECORD,,
24
+ hishel-0.0.31.dist-info/METADATA,sha256=-hIw1fiLfsgB3RmeHqw4odYGvdE4iezkjqZijkD6JvM,11478
25
+ hishel-0.0.31.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
26
+ hishel-0.0.31.dist-info/licenses/LICENSE,sha256=1qQj7pE0V2O9OIedvyOgLGLvZLaPd3nFEup3IBEOZjQ,1493
27
+ hishel-0.0.31.dist-info/RECORD,,