anydi 0.32.0__tar.gz → 0.32.2__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 (32) hide show
  1. {anydi-0.32.0 → anydi-0.32.2}/PKG-INFO +1 -1
  2. {anydi-0.32.0 → anydi-0.32.2}/anydi/_context.py +6 -2
  3. {anydi-0.32.0 → anydi-0.32.2}/anydi/_provider.py +7 -1
  4. {anydi-0.32.0 → anydi-0.32.2}/pyproject.toml +1 -1
  5. {anydi-0.32.0 → anydi-0.32.2}/LICENSE +0 -0
  6. {anydi-0.32.0 → anydi-0.32.2}/README.md +0 -0
  7. {anydi-0.32.0 → anydi-0.32.2}/anydi/__init__.py +0 -0
  8. {anydi-0.32.0 → anydi-0.32.2}/anydi/_container.py +0 -0
  9. {anydi-0.32.0 → anydi-0.32.2}/anydi/_injector.py +0 -0
  10. {anydi-0.32.0 → anydi-0.32.2}/anydi/_logger.py +0 -0
  11. {anydi-0.32.0 → anydi-0.32.2}/anydi/_module.py +0 -0
  12. {anydi-0.32.0 → anydi-0.32.2}/anydi/_scanner.py +0 -0
  13. {anydi-0.32.0 → anydi-0.32.2}/anydi/_types.py +0 -0
  14. {anydi-0.32.0 → anydi-0.32.2}/anydi/_utils.py +0 -0
  15. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/__init__.py +0 -0
  16. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/_utils.py +0 -0
  17. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/django/__init__.py +0 -0
  18. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/django/_container.py +0 -0
  19. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/django/_settings.py +0 -0
  20. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/django/_utils.py +0 -0
  21. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/django/apps.py +0 -0
  22. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/django/middleware.py +0 -0
  23. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/django/ninja/__init__.py +0 -0
  24. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/django/ninja/_operation.py +0 -0
  25. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/django/ninja/_signature.py +0 -0
  26. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/fastapi.py +0 -0
  27. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/faststream.py +0 -0
  28. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/pydantic_settings.py +0 -0
  29. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/pytest_plugin.py +0 -0
  30. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/starlette/__init__.py +0 -0
  31. {anydi-0.32.0 → anydi-0.32.2}/anydi/ext/starlette/middleware.py +0 -0
  32. {anydi-0.32.0 → anydi-0.32.2}/anydi/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: anydi
3
- Version: 0.32.0
3
+ Version: 0.32.2
4
4
  Summary: Dependency Injection library
5
5
  Home-page: https://github.com/antonrh/anydi
6
6
  License: MIT
@@ -86,7 +86,9 @@ class ScopedContext(abc.ABC):
86
86
  kwargs: dict[str, Any] = {}
87
87
 
88
88
  for parameter in provider.parameters:
89
- if parameter.annotation in self._instances:
89
+ if parameter.annotation in self.container._override_instances: # noqa
90
+ instance = self.container._override_instances[parameter.annotation] # noqa
91
+ elif parameter.annotation in self._instances:
90
92
  instance = self._instances[parameter.annotation]
91
93
  else:
92
94
  instance = self._resolve_parameter(provider, parameter)
@@ -104,7 +106,9 @@ class ScopedContext(abc.ABC):
104
106
  kwargs: dict[str, Any] = {}
105
107
 
106
108
  for parameter in provider.parameters:
107
- if parameter.annotation in self._instances:
109
+ if parameter.annotation in self.container._override_instances: # noqa
110
+ instance = self.container._override_instances[parameter.annotation] # noqa
111
+ elif parameter.annotation in self._instances:
108
112
  instance = self._instances[parameter.annotation]
109
113
  else:
110
114
  instance = await self._aresolve_parameter(provider, parameter)
@@ -41,7 +41,7 @@ class Provider:
41
41
  )
42
42
 
43
43
  def __init__(
44
- self, *, call: Callable[..., Any], scope: Scope, interface: Any = _sentinel
44
+ self, call: Callable[..., Any], *, scope: Scope, interface: Any = _sentinel
45
45
  ) -> None:
46
46
  self._call = call
47
47
  self._call_module = getattr(call, "__module__", None)
@@ -106,6 +106,12 @@ class Provider:
106
106
 
107
107
  def _validate_scope(self) -> None:
108
108
  """Validate the scope of the provider."""
109
+ if self.scope not in get_args(Scope):
110
+ raise ValueError(
111
+ "The scope provided is invalid. Only the following scopes are "
112
+ f"supported: {', '.join(get_args(Scope))}. Please use one of the "
113
+ "supported scopes when registering a provider."
114
+ )
109
115
  if self.is_resource and self.scope == "transient":
110
116
  raise TypeError(
111
117
  f"The resource provider `{self}` is attempting to register "
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "anydi"
3
- version = "0.32.0"
3
+ version = "0.32.2"
4
4
  description = "Dependency Injection library"
5
5
  authors = ["Anton Ruhlov <antonruhlov@gmail.com>"]
6
6
  license = "MIT"
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