Resolves all dependencies and returns a new instance of `type_` using constructor dependency injection. Note that only positional arguments or arguments with defaults are resolved. Varargs and keyword-only args are ignored. Dependencies are resolved with the followi
(self, type_: Type[T])
| 109 | |
| 110 | @no_type_check |
| 111 | def resolve(self, type_: Type[T]) -> T: |
| 112 | """ |
| 113 | Resolves all dependencies and returns a new instance of `type_` using constructor dependency |
| 114 | injection. Note that only positional arguments or arguments with defaults are resolved. |
| 115 | Varargs and keyword-only args are ignored. |
| 116 | |
| 117 | Dependencies are resolved with the following precedence |
| 118 | |
| 119 | 1. Conventions |
| 120 | 2. Types, Instances |
| 121 | |
| 122 | :param **type_**: A `type` (class) to construct |
| 123 | :return: An instance of **type_** |
| 124 | :raises UnresolvableDependencyError: If any dependencies could not be successfully resolved |
| 125 | """ |
| 126 | with suppress(UnresolvableDependencyError): |
| 127 | return self._resolve_type(type_) |
| 128 | |
| 129 | args = self.resolve_dependencies(type_) |
| 130 | return type_(*args) |
| 131 | |
| 132 | def resolve_dependencies(self, type_: Type[T]) -> Sequence[Any]: |
| 133 | """ |
no test coverage detected