zstdlib 0.10.9__tar.gz → 0.10.10__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.
Files changed (48) hide show
  1. {zstdlib-0.10.9 → zstdlib-0.10.10}/PKG-INFO +1 -1
  2. {zstdlib-0.10.9 → zstdlib-0.10.10}/pyproject.toml +1 -0
  3. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_singleton.py +1 -1
  4. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/__init__.py +1 -1
  5. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/singleton.py +9 -16
  6. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib.egg-info/PKG-INFO +1 -1
  7. {zstdlib-0.10.9 → zstdlib-0.10.10}/LICENSE +0 -0
  8. {zstdlib-0.10.9 → zstdlib-0.10.10}/README.md +0 -0
  9. {zstdlib-0.10.9 → zstdlib-0.10.10}/setup.cfg +0 -0
  10. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/__init__.py +0 -0
  11. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/log/__init__.py +0 -0
  12. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/log/base.py +0 -0
  13. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/log/test_cute.py +0 -0
  14. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/log/test_trace.py +0 -0
  15. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_ansi.py +0 -0
  16. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_enum.py +0 -0
  17. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_exc_capture.py +0 -0
  18. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_frozen.py +0 -0
  19. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_hybridmethod.py +0 -0
  20. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_io.py +0 -0
  21. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_ip_lock.py +0 -0
  22. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_keyed_instance.py +0 -0
  23. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_lazy.py +0 -0
  24. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_not_set.py +0 -0
  25. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_prompt.py +0 -0
  26. {zstdlib-0.10.9 → zstdlib-0.10.10}/tests/test_util.py +0 -0
  27. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/ansi.py +0 -0
  28. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/enum.py +0 -0
  29. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/exc_capture.py +0 -0
  30. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/frozen.py +0 -0
  31. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/hybridmethod.py +0 -0
  32. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/io.py +0 -0
  33. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/ip_lock.py +0 -0
  34. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/keyed_instance.py +0 -0
  35. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/lazy.py +0 -0
  36. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/log/__init__.py +0 -0
  37. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/log/cute.py +0 -0
  38. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/log/trace.py +0 -0
  39. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/macos.py +0 -0
  40. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/not_set.py +0 -0
  41. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/prompt.py +0 -0
  42. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/py.typed +0 -0
  43. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/signal_cm.py +0 -0
  44. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib/util.py +0 -0
  45. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib.egg-info/SOURCES.txt +0 -0
  46. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib.egg-info/dependency_links.txt +0 -0
  47. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib.egg-info/requires.txt +0 -0
  48. {zstdlib-0.10.9 → zstdlib-0.10.10}/zstdlib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zstdlib
3
- Version: 0.10.9
3
+ Version: 0.10.10
4
4
  Summary: A set of useful python utilities
5
5
  License-Expression: GPL-3.0-only
6
6
  Project-URL: Homepage, https://github.com/zwimer/zstdlib
@@ -62,6 +62,7 @@ line-length = 110
62
62
  [tool.ruff.lint]
63
63
  ignore=[
64
64
  "ANN401",
65
+ "B019",
65
66
  "D10", "D2", "D403", "D415",
66
67
  "E731",
67
68
  "I001",
@@ -48,7 +48,7 @@ class TestSingleton(unittest.TestCase):
48
48
  self.assertIs(ST.instance(), obj)
49
49
 
50
50
  with self.assertRaises(TypeError):
51
- ST.instance(4) # type: ignore[call-arg]
51
+ ST.instance(4)
52
52
 
53
53
  def test_multi_thread(self) -> None:
54
54
  """Ensure that Singleton is thread safe and that constructing an object doesn't delay other threads
@@ -1,4 +1,4 @@
1
- __version__ = "0.10.9"
1
+ __version__ = "0.10.10"
2
2
 
3
3
  from .ip_lock import AbstractIPLock, GlobalIPLock, IPLock, LockHung, LockPathInUse, NotAcquired, RIPLock
4
4
  from .keyed_instance import CircularConstruction, KeyedInstance
@@ -1,4 +1,4 @@
1
- from typing import ClassVar, Never, Any
1
+ from typing import ClassVar, Never, Any, cast
2
2
  from collections import defaultdict
3
3
  from threading import RLock
4
4
  from functools import cache
@@ -46,30 +46,23 @@ class _SingletonType(type):
46
46
  ret = cls._instances[cls] = super().__call__(*args, **kwargs)
47
47
  return ret
48
48
 
49
- @classmethod
50
49
  @cache
51
- def instance(mcs, t: type[Singleton]) -> Singleton:
50
+ def instance[T: Singleton](cls: type[T]) -> T:
52
51
  """Get the instance of cls"""
53
- if not isinstance(t, mcs):
54
- raise TypeError(f"{t} is not a Singleton type")
52
+ # pylint: disable=protected-access
53
+ mcs = cast(_SingletonType, type(cls)) # mypy can't figure this out :/
55
54
  with mcs._lock:
56
- cls_lock = mcs._cls_locks[t]
55
+ cls_lock = mcs._cls_locks[cls]
57
56
  with cls_lock:
58
- if (got := mcs._instances.get(t, None)) is None:
59
- raise NoInstanceError(f"No instance of {t} found")
60
- return got
57
+ if (got := mcs._instances.get(cls, None)) is None:
58
+ raise NoInstanceError(f"No instance of {cls.__qualname__} found")
59
+ # pylint: enable=protected-access
60
+ return cast(T, got)
61
61
 
62
62
 
63
63
  class Singleton(metaclass=_SingletonType):
64
64
  """A thread-safe singleton base class"""
65
65
 
66
- @classmethod
67
- def instance(cls) -> Singleton:
68
- """Blocking get the instance of cls; raise if not constructed"""
69
- assert isinstance(cls, _SingletonType), "Metaclass should be _SingletonType"
70
- tc: type[_SingletonType] = type(cls)
71
- return tc.instance(cls)
72
-
73
66
  def __init_subclass__(cls, *args: Any, **kwargs: Any) -> None:
74
67
  """Disallow subclassing"""
75
68
  cls.__init_subclass__ = _no_subclass # type: ignore[method-assign]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zstdlib
3
- Version: 0.10.9
3
+ Version: 0.10.10
4
4
  Summary: A set of useful python utilities
5
5
  License-Expression: GPL-3.0-only
6
6
  Project-URL: Homepage, https://github.com/zwimer/zstdlib
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes