dependency-injection-pattern 0.0.4__tar.gz → 0.0.5__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 (40) hide show
  1. {dependency_injection_pattern-0.0.4/src/dependency_injection_pattern.egg-info → dependency_injection_pattern-0.0.5}/PKG-INFO +3 -3
  2. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/pyproject.toml +2 -2
  3. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5/src/dependency_injection_pattern.egg-info}/PKG-INFO +3 -3
  4. dependency_injection_pattern-0.0.5/src/dependency_injection_pattern.egg-info/requires.txt +6 -0
  5. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/container.py +4 -4
  6. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/default_scope.py +1 -1
  7. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/factories/factory.py +2 -2
  8. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/helpers.py +1 -2
  9. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/provider.py +1 -1
  10. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/tests/test_container.py +1 -1
  11. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/tests/test_examples.py +1 -0
  12. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/tests/test_factory.py +1 -0
  13. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/tests/test_provider.py +1 -0
  14. dependency_injection_pattern-0.0.4/src/dependency_injection_pattern.egg-info/requires.txt +0 -6
  15. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/LICENSE +0 -0
  16. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/README.md +0 -0
  17. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/setup.cfg +0 -0
  18. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/dependency_injection_pattern.egg-info/SOURCES.txt +0 -0
  19. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/dependency_injection_pattern.egg-info/dependency_links.txt +0 -0
  20. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/dependency_injection_pattern.egg-info/top_level.txt +0 -0
  21. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/__init__.py +0 -0
  22. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/exceptions/add_exception.py +0 -0
  23. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/exceptions/container_sealed_error.py +0 -0
  24. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/exceptions/factory_provide_exception.py +0 -0
  25. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/exceptions/implementation_exception.py +0 -0
  26. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/exceptions/provide_exception.py +0 -0
  27. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/exceptions/seal_exception.py +0 -0
  28. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/factories/dependency.py +0 -0
  29. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/factories/scoped_factory.py +0 -0
  30. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/factories/singleton_factory.py +0 -0
  31. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/factories/transient_factory.py +0 -0
  32. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/factory.py +0 -0
  33. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/log.py +0 -0
  34. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/named_service.py +0 -0
  35. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/protocols/container.py +0 -0
  36. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/protocols/factory.py +0 -0
  37. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/protocols/provider.py +0 -0
  38. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/scope.py +0 -0
  39. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/core/service_request.py +0 -0
  40. {dependency_injection_pattern-0.0.4 → dependency_injection_pattern-0.0.5}/src/di/exceptions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dependency-injection-pattern
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: Python implementation of the Dependency Injection pattern.
5
5
  Author-email: Anders Madsen <anders.madsen@alphavue.com>
6
6
  License-Expression: MIT
@@ -25,8 +25,8 @@ Classifier: Typing :: Typed
25
25
  Requires-Python: >=3.10
26
26
  Description-Content-Type: text/markdown
27
27
  License-File: LICENSE
28
- Requires-Dist: typing-utilities<0.1,>=0.0.3
29
- Requires-Dist: runtime-reflection-lite<0.2,>=0.1.0
28
+ Requires-Dist: typing-utilities<0.2,>=0.1.0
29
+ Requires-Dist: runtime-reflection-lite<0.2,>=0.1.2
30
30
  Provides-Extra: test
31
31
  Requires-Dist: pytest>=8.3; extra == "test"
32
32
  Requires-Dist: pytest-cov>=6.1; extra == "test"
@@ -28,8 +28,8 @@ classifiers = [
28
28
  "Typing :: Typed"
29
29
  ]
30
30
  dependencies = [
31
- "typing-utilities >= 0.0.3, < 0.1",
32
- "runtime-reflection-lite >= 0.1.0, < 0.2"
31
+ "typing-utilities >= 0.1.0, < 0.2",
32
+ "runtime-reflection-lite >= 0.1.2, < 0.2"
33
33
  ]
34
34
  requires-python = ">=3.10"
35
35
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dependency-injection-pattern
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: Python implementation of the Dependency Injection pattern.
5
5
  Author-email: Anders Madsen <anders.madsen@alphavue.com>
6
6
  License-Expression: MIT
@@ -25,8 +25,8 @@ Classifier: Typing :: Typed
25
25
  Requires-Python: >=3.10
26
26
  Description-Content-Type: text/markdown
27
27
  License-File: LICENSE
28
- Requires-Dist: typing-utilities<0.1,>=0.0.3
29
- Requires-Dist: runtime-reflection-lite<0.2,>=0.1.0
28
+ Requires-Dist: typing-utilities<0.2,>=0.1.0
29
+ Requires-Dist: runtime-reflection-lite<0.2,>=0.1.2
30
30
  Provides-Extra: test
31
31
  Requires-Dist: pytest>=8.3; extra == "test"
32
32
  Requires-Dist: pytest-cov>=6.1; extra == "test"
@@ -0,0 +1,6 @@
1
+ typing-utilities<0.2,>=0.1.0
2
+ runtime-reflection-lite<0.2,>=0.1.2
3
+
4
+ [test]
5
+ pytest>=8.3
6
+ pytest-cov>=6.1
@@ -195,7 +195,7 @@ class Container:
195
195
  factories = { **self.__factories, **{ service: factory for service, factory in self.__named_factories.values() } }
196
196
  for service, factory in factories.items():
197
197
  for dep in factory.dependencies.values():
198
- if not dep.service in factories:
198
+ if dep.service not in factories:
199
199
  if not dep.is_optional and not dep.has_default:
200
200
  raise SealException(f"Service '{get_service_name(service)}' depends on service '{get_service_name(dep.service)}' which is not defined in container.")
201
201
  else:
@@ -207,7 +207,7 @@ class Container:
207
207
  raise SealException(f"Singleton service '{get_service_name(service)}' depends on transient service {get_service_name(dep.service)}' which is not permitted.")
208
208
 
209
209
  return provider
210
- elif provider :=self.__provider():
210
+ elif provider := self.__provider():
211
211
  return provider
212
212
  else:
213
213
  provider = Provider(self)
@@ -215,7 +215,7 @@ class Container:
215
215
  return provider
216
216
 
217
217
  def __add_factory_pre(self, factory_type: type[Factory[T]], *args: Any) -> tuple[str, type[Any]]:
218
- if self.__provider != None:
218
+ if self.__provider is not None:
219
219
  raise ContainerSealedError
220
220
 
221
221
  if len(args) == 2:
@@ -335,7 +335,7 @@ class Container:
335
335
 
336
336
  if factory:
337
337
  return factory
338
- elif default != None:
338
+ elif default is not None:
339
339
  return default
340
340
  elif not is_optional:
341
341
  if isinstance(service, ServiceRequest):
@@ -55,7 +55,7 @@ class DefaultScope(Scope):
55
55
  self.__local.finalizer = Thread(target = finalize, args = [ current_thread(), dict ])
56
56
  self.__local.finalizer.start()
57
57
 
58
- if not service in self.__local.dict:
58
+ if service not in self.__local.dict:
59
59
  impl = factory()
60
60
  if current_thread() != main_thread() and is_context(service):
61
61
  # finalizer is only implemented when thread is not main thread, otherwise object would never be exited (eg. finalized)
@@ -30,7 +30,7 @@ class Factory(Generic[T]):
30
30
  sig = get_constructor(service)
31
31
  elif isinstance(implementation, type):
32
32
  sig = get_constructor(cast(type, implementation))
33
- if not service is NamedService and not issubclass_typing(implementation, service):
33
+ if service is not NamedService and not issubclass_typing(implementation, service):
34
34
  raise ImplementationException(service, implementation, "Implementation class is not derived from service")
35
35
  elif implementation is service:
36
36
  raise ImplementationException(service, implementation, "Implementation equals service")
@@ -54,7 +54,7 @@ class Factory(Generic[T]):
54
54
  else:
55
55
  raise ImplementationException(service, implementation, "Implementation does not resolve into a class derived from service")
56
56
 
57
- if sig != None:
57
+ if sig is not None:
58
58
  parameters = [ p for p in sig.parameters if p.kind == ParameterKind.POSITIONAL_OR_KEYWORD ]
59
59
  missing_annotations = [ p.name for p in parameters if not p.parameter_type ]
60
60
  self.__dependencies = { p.name: Dependency(p.name, p.parameter_type, p.default) for p in parameters }
@@ -1,5 +1,4 @@
1
1
  from typing import MutableMapping, Protocol, TypeVar, cast, runtime_checkable
2
- from di.core.factory import Factory
3
2
  from types import TracebackType
4
3
  from typingutils import AnyType, issubclass_typing, get_type_name
5
4
 
@@ -35,7 +34,7 @@ def get_provided_service_from_annotation(annotation: AnyType) -> tuple[AnyType,
35
34
  __CONTEXT_SERVICES__: MutableMapping[type, bool] = {}
36
35
 
37
36
  def is_context(cls: type) -> bool:
38
- if not cls in __CONTEXT_SERVICES__:
37
+ if cls not in __CONTEXT_SERVICES__:
39
38
  # reflection = reflect_class(cls)
40
39
 
41
40
  # if "__enter__" in reflection.functions and "__exit__" in reflection.functions:
@@ -68,7 +68,7 @@ class Provider:
68
68
  else:
69
69
  result = self.__container._get(cast(type[T], service)) # pyright: ignore[reportPrivateUsage]
70
70
 
71
- if result == None:
71
+ if result is None:
72
72
  # optional requirements may return None
73
73
  if is_optional:
74
74
  return None # pyright: ignore[reportReturnType]
@@ -1,5 +1,5 @@
1
1
  # pyright: basic
2
- # from __future__ import annotations
2
+ # ruff: noqa
3
3
  from typing import cast, Sequence
4
4
  from pytest import raises as assert_raises
5
5
  from threading import Thread
@@ -1,4 +1,5 @@
1
1
  # pyright: basic
2
+ # ruff: noqa
2
3
 
3
4
  def test_example_1():
4
5
  from logging import Logger
@@ -1,4 +1,5 @@
1
1
  # pyright: basic
2
+ # ruff: noqa
2
3
  from __future__ import annotations
3
4
  from time import sleep
4
5
  from threading import Thread
@@ -1,4 +1,5 @@
1
1
  # pyright: basic
2
+ # ruff: noqa
2
3
  from typing import cast, Sequence, MutableSequence, Generic, TypeVar, Any, ClassVar
3
4
  from pytest import raises as assert_raises
4
5
 
@@ -1,6 +0,0 @@
1
- typing-utilities<0.1,>=0.0.3
2
- runtime-reflection-lite<0.2,>=0.1.0
3
-
4
- [test]
5
- pytest>=8.3
6
- pytest-cov>=6.1