Common: Add note about varargs and kwargs to resolve() docstring

This commit is contained in:
Mike Salvatore 2022-04-26 01:27:17 -04:00
parent 7a62434364
commit e78bffb414
1 changed files with 2 additions and 2 deletions

View File

@ -37,7 +37,8 @@ class DIContainer:
def resolve(self, type_: Type[T]) -> T: def resolve(self, type_: Type[T]) -> T:
""" """
Resolves all dependencies and returns a new instance of `type_` using constructor dependency Resolves all dependencies and returns a new instance of `type_` using constructor dependency
injection. injection. Note that only positional arguments are resolved. Varargs, keyword-only args, and
default values are ignored.
:param type_: A type (class) to construct. :param type_: A type (class) to construct.
:return: An instance of `type_` :return: An instance of `type_`
@ -49,7 +50,6 @@ class DIContainer:
args = [] args = []
# TODO: Need to handle keyword-only arguments, defaults, varargs, etc.
for arg_type in inspect.getfullargspec(type_).annotations.values(): for arg_type in inspect.getfullargspec(type_).annotations.values():
instance = self._resolve_type(arg_type) instance = self._resolve_type(arg_type)
args.append(instance) args.append(instance)