python-injection 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 (22) hide show
  1. {python_injection-0.10.9 → python_injection-0.10.10}/PKG-INFO +1 -1
  2. {python_injection-0.10.9 → python_injection-0.10.10}/injection/integrations/fastapi.py +12 -4
  3. {python_injection-0.10.9 → python_injection-0.10.10}/pyproject.toml +2 -1
  4. {python_injection-0.10.9 → python_injection-0.10.10}/README.md +0 -0
  5. {python_injection-0.10.9 → python_injection-0.10.10}/injection/__init__.py +0 -0
  6. {python_injection-0.10.9 → python_injection-0.10.10}/injection/__init__.pyi +0 -0
  7. {python_injection-0.10.9 → python_injection-0.10.10}/injection/_core/__init__.py +0 -0
  8. {python_injection-0.10.9 → python_injection-0.10.10}/injection/_core/common/__init__.py +0 -0
  9. {python_injection-0.10.9 → python_injection-0.10.10}/injection/_core/common/event.py +0 -0
  10. {python_injection-0.10.9 → python_injection-0.10.10}/injection/_core/common/invertible.py +0 -0
  11. {python_injection-0.10.9 → python_injection-0.10.10}/injection/_core/common/lazy.py +0 -0
  12. {python_injection-0.10.9 → python_injection-0.10.10}/injection/_core/common/threading.py +0 -0
  13. {python_injection-0.10.9 → python_injection-0.10.10}/injection/_core/common/type.py +0 -0
  14. {python_injection-0.10.9 → python_injection-0.10.10}/injection/_core/hook.py +0 -0
  15. {python_injection-0.10.9 → python_injection-0.10.10}/injection/_core/module.py +0 -0
  16. {python_injection-0.10.9 → python_injection-0.10.10}/injection/exceptions.py +0 -0
  17. {python_injection-0.10.9 → python_injection-0.10.10}/injection/integrations/__init__.py +0 -0
  18. {python_injection-0.10.9 → python_injection-0.10.10}/injection/integrations/blacksheep.py +0 -0
  19. {python_injection-0.10.9 → python_injection-0.10.10}/injection/py.typed +0 -0
  20. {python_injection-0.10.9 → python_injection-0.10.10}/injection/testing/__init__.py +0 -0
  21. {python_injection-0.10.9 → python_injection-0.10.10}/injection/testing/__init__.pyi +0 -0
  22. {python_injection-0.10.9 → python_injection-0.10.10}/injection/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-injection
3
- Version: 0.10.9
3
+ Version: 0.10.10
4
4
  Summary: Fast and easy dependency injection framework.
5
5
  Home-page: https://github.com/100nm/python-injection
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  from collections.abc import Callable
2
2
  from types import GenericAlias
3
- from typing import Any, ClassVar, TypeAliasType
3
+ from typing import Any, ClassVar, Self, TypeAliasType
4
4
 
5
5
  from injection import Module, mod
6
6
  from injection.exceptions import InjectionError
@@ -28,10 +28,11 @@ def Inject[T]( # noqa: N802
28
28
 
29
29
 
30
30
  class InjectionDependency[T]:
31
- __slots__ = ("__call__", "__class")
31
+ __slots__ = ("__call__", "__class", "__module")
32
32
 
33
33
  __call__: Callable[[], T]
34
34
  __class: type[T] | TypeAliasType | GenericAlias
35
+ __module: Module
35
36
 
36
37
  __sentinel: ClassVar[object] = object()
37
38
 
@@ -39,15 +40,22 @@ class InjectionDependency[T]:
39
40
  lazy_instance = module.get_lazy_instance(cls, default=self.__sentinel)
40
41
  self.__call__ = lambda: self.__ensure(~lazy_instance)
41
42
  self.__class = cls
43
+ self.__module = module
42
44
 
43
45
  def __eq__(self, other: Any) -> bool:
44
46
  if isinstance(other, type(self)):
45
- return hash(self) == hash(other)
47
+ return self.__key == other.__key
46
48
 
47
49
  return NotImplemented
48
50
 
49
51
  def __hash__(self) -> int:
50
- return hash((self.__class,))
52
+ return hash(self.__key)
53
+
54
+ @property
55
+ def __key(
56
+ self,
57
+ ) -> tuple[type[Self], type[T] | TypeAliasType | GenericAlias, Module]:
58
+ return type(self), self.__class, self.__module
51
59
 
52
60
  def __ensure(self, instance: T | Any) -> T:
53
61
  if instance is self.__sentinel:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-injection"
3
- version = "0.10.9"
3
+ version = "0.10.10"
4
4
  description = "Fast and easy dependency injection framework."
5
5
  license = "MIT"
6
6
  authors = ["remimd"]
@@ -54,6 +54,7 @@ exclude_lines = [
54
54
  "pass",
55
55
  "pragma: no cover",
56
56
  "raise NotImplementedError",
57
+ "return NotImplemented",
57
58
  ]
58
59
 
59
60
  [tool.coverage.run]