def _build_class_spec(name, dependency): if _using_object_init(dependency): return _Spec(dependency, {}, set(), set()) else: name = dependency.__name__ + "." + "__init__" owner = f"{dependency.__name__!r} class" args, required, optional = _method_args(dependency.__init__, name, owner) return _Spec(dependency, args, required, optional)
def _build_value_spec(name, dependency): function = dependency.__function__ name = function.__name__ owner = f"{name!r} value" args, required, optional = _function_args(function, name, owner) _check_method(args) return _Spec(function, args, required, optional)
def _build_attributes_spec(name, dependency): origin_spec = yield dependency.origin return _Spec( _AttributesFactory(origin_spec.factory, dependency.attrs), origin_spec.args, origin_spec.required, origin_spec.optional, )
def __call__(self, __self__): parent = _Spec(ref(__self__), {}, set(), set()) subclass = type(self.injector.__name__, (self.injector, ), _NonEmptyNamespace()) subclass.__dependencies__.specs["__parent__"] = parent return subclass
def _build_nested_injector_spec(name, dependency): return _Spec(_NestedInjectorFactory(dependency), {"__self__": False}, {"__self__"}, set())
def _build_package_spec(name, dependency): return _Spec(_ImportFactory(dependency), {}, set(), set())
def _build_data_spec(name, dependency): return _Spec(lambda: dependency, {}, set(), set())
def _build_this_spec(name, dependency): expression = dependency.__expression__ _check_expression(expression) return _Spec(_ThisFactory(expression), {"__self__": False}, {"__self__"}, set())