CacheToolsUtils 11.0__tar.gz → 12.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: CacheToolsUtils
3
- Version: 11.0
3
+ Version: 12.0
4
4
  Summary: Cachetools Utilities
5
5
  Author-email: Fabien Coelho <cachetools.utils@coelho.net>
6
6
  License-Expression: CC0-1.0
@@ -5,7 +5,8 @@ CacheTools Utilities. This code is public domain.
5
5
  # FIXME 3.13t checks without Cipher package
6
6
  # pyright: reportMissingImports=false
7
7
 
8
- from typing import Any, Callable, MutableMapping
8
+ from typing import Any
9
+ from collections.abc import Callable, MutableMapping
9
10
  import abc
10
11
 
11
12
  import base64
@@ -27,6 +28,10 @@ log = logging.getLogger(__name__)
27
28
  _NO_DEFAULT = object()
28
29
 
29
30
 
31
+ class CTUError(Exception):
32
+ pass
33
+
34
+
30
35
  class _MutMapMix:
31
36
  """Convenient MutableMapping Mixin, forward to `_cache`."""
32
37
 
@@ -167,7 +172,7 @@ class DictCache(_MutMapMix, MutableMapping):
167
172
  """Cache class based on `dict`."""
168
173
 
169
174
  def __init__(self):
170
- self._cache = dict()
175
+ self._cache = {}
171
176
 
172
177
  def clear(self):
173
178
  self._cache.clear()
@@ -261,7 +266,7 @@ class AutoPrefixedCache(PrefixedCache):
261
266
 
262
267
  def __init__(self, cache: MutableMapping, sep: str = ".", method: str = "b64"):
263
268
  if method not in AutoPrefixedCache._METHODS:
264
- raise Exception(f"invalid conversion method: {method}")
269
+ raise CTUError(f"invalid conversion method: {method}")
265
270
  encoder = AutoPrefixedCache._METHODS[method]
266
271
  length = max(1, (AutoPrefixedCache._COUNTER.bit_length() + 7) // 8)
267
272
  # NOTE byteorder default added to 3.11
@@ -445,7 +450,7 @@ class _Cipher:
445
450
  kwargs = {"mode": cipher.MODE_CBC}
446
451
  size = 16
447
452
  else:
448
- raise Exception(f"unexpected cipher: {name}")
453
+ raise CTUError(f"unexpected cipher: {name}")
449
454
  self._cipher = cipher
450
455
  self._params = params
451
456
  self._kwargs = kwargs
@@ -699,7 +704,7 @@ class _HashJsonKey:
699
704
  return self._key
700
705
 
701
706
 
702
- # NOTE not very useful, behaves as _HashJsonKey.
707
+ # NOTE not very useful, behaves as _HashJsonKey, but is not a class.
703
708
  def hash_json_key(*args, **kwargs):
704
709
  """Function handling of above class, to keep it hidden."""
705
710
  return _HashJsonKey(*args, **kwargs)
@@ -743,7 +748,7 @@ class JsonSerde:
743
748
  elif flag == 3:
744
749
  return json.loads(value.decode("utf-8"))
745
750
  else:
746
- raise Exception(f"Unknown serialization format: {flag}")
751
+ raise CTUError(f"Unknown serialization format: {flag}")
747
752
 
748
753
 
749
754
  class MemCached(_KeyMutMapMix, MutableMapping):
@@ -875,7 +880,7 @@ class RedisCache(MutableMapping):
875
880
  return self._cache.dbsize()
876
881
 
877
882
  def __iter__(self):
878
- raise Exception("not implemented yet")
883
+ raise NotImplementedError("not implemented yet")
879
884
 
880
885
  def info(self, *args, **kwargs):
881
886
  """Return redis informations."""
@@ -947,5 +952,3 @@ class StatsRedisCache(PrefixedRedisCache):
947
952
 
948
953
  def flushdb(self):
949
954
  self._cache.clear()
950
-
951
- pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: CacheToolsUtils
3
- Version: 11.0
3
+ Version: 12.0
4
4
  Summary: Cachetools Utilities
5
5
  Author-email: Fabien Coelho <cachetools.utils@coelho.net>
6
6
  License-Expression: CC0-1.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "CacheToolsUtils"
7
- version = "11.0"
7
+ version = "12.0"
8
8
  authors = [ { name = "Fabien Coelho", email = "cachetools.utils@coelho.net" } ]
9
9
  description = "Cachetools Utilities"
10
10
  readme = "README.md"
@@ -40,3 +40,7 @@ doc = [ "mkdocs", "mkdocs-material", "mkdocstrings[python]" ]
40
40
  crypt = [ "pycryptodome" ]
41
41
  tests = [ "pymemcache", "redis" ]
42
42
  pub = [ "build", "wheel", "twine" ]
43
+
44
+ [tool.ruff.lint]
45
+ # ruff rules are what they are, but they are not always right
46
+ ignore = ["BLE001", "B006", "I001", "RUF012"]
File without changes
File without changes
File without changes