diff --git a/docs/main/changelog.rst b/docs/main/changelog.rst index ecc656bc..b07283bd 100644 --- a/docs/main/changelog.rst +++ b/docs/main/changelog.rst @@ -7,6 +7,10 @@ that were made in every particular version. From version 0.7.6 *Dependency Injector* framework strictly follows `Semantic versioning`_ +Development version +------------------- +- Improve error message for ``Dependency`` provider missing attribute. + 4.25.1 ------ - Amend docs and add another example for ``@containers.copy()`` decorator. diff --git a/src/dependency_injector/providers.c b/src/dependency_injector/providers.c index 37efd4fd..3afb77b9 100644 --- a/src/dependency_injector/providers.c +++ b/src/dependency_injector/providers.c @@ -3561,18 +3561,18 @@ static PyObject *__pyx_builtin_IndexError; static PyObject *__pyx_builtin_DeprecationWarning; static PyObject *__pyx_builtin_NotImplementedError; static PyObject *__pyx_builtin_TypeError; -static PyObject *__pyx_builtin_hex; static PyObject *__pyx_builtin_AttributeError; +static PyObject *__pyx_builtin_hex; static PyObject *__pyx_builtin_filter; static PyObject *__pyx_builtin_IOError; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_KeyError; static PyObject *__pyx_builtin_StopIteration; static const char __pyx_k__2[] = "_"; -static const char __pyx_k__5[] = "<"; -static const char __pyx_k__6[] = "."; -static const char __pyx_k__7[] = "("; -static const char __pyx_k__8[] = "\""; +static const char __pyx_k__5[] = "\""; +static const char __pyx_k__6[] = "<"; +static const char __pyx_k__7[] = "."; +static const char __pyx_k__8[] = "("; static const char __pyx_k__9[] = ">"; static const char __pyx_k_at[] = ") at "; static const char __pyx_k_id[] = "id"; @@ -3694,7 +3694,6 @@ static const char __pyx_k_default[] = "default"; static const char __pyx_k_environ[] = "environ"; static const char __pyx_k_factory[] = "factory"; static const char __pyx_k_genexpr[] = "genexpr"; -static const char __pyx_k_getattr[] = "__getattr__"; static const char __pyx_k_im_func[] = "im_func"; static const char __pyx_k_im_self[] = "im_self"; static const char __pyx_k_inspect[] = "inspect"; @@ -3708,7 +3707,7 @@ static const char __pyx_k_visited[] = "visited"; static const char __pyx_k_Callable[] = "Callable"; static const char __pyx_k_Delegate[] = "Delegate"; static const char __pyx_k_KeyError[] = "KeyError"; -static const char __pyx_k_Provider[] = "Provider"; +static const char __pyx_k_Provider[] = "Provider \""; static const char __pyx_k_Resource[] = "Resource"; static const char __pyx_k_Selector[] = "Selector"; static const char __pyx_k_StringIO[] = "StringIO"; @@ -3771,6 +3770,7 @@ static const char __pyx_k_IndexError[] = "IndexError"; static const char __pyx_k_ItemGetter[] = "ItemGetter"; static const char __pyx_k_List___get[] = "List.__get__"; static const char __pyx_k_MethodType[] = "MethodType"; +static const char __pyx_k_Provider_2[] = "Provider"; static const char __pyx_k_SafeLoader[] = "SafeLoader"; static const char __pyx_k_ValueError[] = "ValueError"; static const char __pyx_k_YamlLoader[] = "YamlLoader"; @@ -3878,6 +3878,7 @@ static const char __pyx_k_ProvidedInstance[] = "ProvidedInstance"; static const char __pyx_k_Providers_module[] = "Providers module."; static const char __pyx_k_clear_attributes[] = "clear_attributes"; static const char __pyx_k_copy_overridings[] = "_copy_overridings"; +static const char __pyx_k_has_no_attribute[] = "\" has no attribute \""; static const char __pyx_k_AbstractCoroutine[] = "AbstractCoroutine"; static const char __pyx_k_AbstractSingleton[] = "AbstractSingleton"; static const char __pyx_k_CoroutineDelegate[] = "CoroutineDelegate"; @@ -4192,11 +4193,12 @@ static PyObject *__pyx_n_s_PickleError; static PyObject *__pyx_n_s_PositionalInjection; static PyObject *__pyx_n_s_ProvidedInstance; static PyObject *__pyx_n_s_ProvidedInstance___get; -static PyObject *__pyx_n_s_Provider; +static PyObject *__pyx_kp_u_Provider; static PyObject *__pyx_kp_s_Provider_0_could_not_be_overridd; static PyObject *__pyx_kp_s_Provider_0_expected_to_get_calla; static PyObject *__pyx_kp_s_Provider_0_expected_to_get_corou; static PyObject *__pyx_kp_s_Provider_0_is_not_overridden; +static PyObject *__pyx_n_s_Provider_2; static PyObject *__pyx_n_s_Provider___get; static PyObject *__pyx_n_s_Pyx_CFunc_object____object; static PyObject *__pyx_n_s_Pyx_CFunc_void____object____ob; @@ -4237,8 +4239,8 @@ static PyObject *__pyx_kp_u__31; static PyObject *__pyx_kp_u__32; static PyObject *__pyx_kp_s__49; static PyObject *__pyx_kp_u__5; -static PyObject *__pyx_kp_s__6; static PyObject *__pyx_kp_u__6; +static PyObject *__pyx_kp_s__7; static PyObject *__pyx_kp_u__7; static PyObject *__pyx_kp_u__8; static PyObject *__pyx_kp_u__9; @@ -4344,8 +4346,8 @@ static PyObject *__pyx_n_s_get_2; static PyObject *__pyx_n_s_get_name; static PyObject *__pyx_n_s_get_self_name; static PyObject *__pyx_n_s_get_self_name_locals_genexpr; -static PyObject *__pyx_n_s_getattr; static PyObject *__pyx_n_s_getstate; +static PyObject *__pyx_kp_u_has_no_attribute; static PyObject *__pyx_n_s_hex; static PyObject *__pyx_n_s_id; static PyObject *__pyx_n_s_im_class; @@ -15698,7 +15700,9 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_10Dependency_6__getat PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_5; + Py_UCS4 __pyx_t_6; + PyObject *__pyx_t_7 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -15745,7 +15749,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_10Dependency_6__getat * return getattr(self.__last_overriding, name) * elif self.__default is not UNDEFINED: # <<<<<<<<<<<<<< * return getattr(self.__default, name) - * return super().__getattr__(name) + * raise AttributeError(f'Provider "{self.__class__.__name__}" has no attribute "{name}"') */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_UNDEFINED); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 686, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); @@ -15758,7 +15762,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_10Dependency_6__getat * return getattr(self.__last_overriding, name) * elif self.__default is not UNDEFINED: * return getattr(self.__default, name) # <<<<<<<<<<<<<< - * return super().__getattr__(name) + * raise AttributeError(f'Provider "{self.__class__.__name__}" has no attribute "{name}"') * */ __Pyx_XDECREF(__pyx_r); @@ -15776,50 +15780,62 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_10Dependency_6__getat * return getattr(self.__last_overriding, name) * elif self.__default is not UNDEFINED: # <<<<<<<<<<<<<< * return getattr(self.__default, name) - * return super().__getattr__(name) + * raise AttributeError(f'Provider "{self.__class__.__name__}" has no attribute "{name}"') */ } /* "dependency_injector/providers.pyx":688 * elif self.__default is not UNDEFINED: * return getattr(self.__default, name) - * return super().__getattr__(name) # <<<<<<<<<<<<<< + * raise AttributeError(f'Provider "{self.__class__.__name__}" has no attribute "{name}"') # <<<<<<<<<<<<<< * * def __str__(self): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 688, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 688, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = 0; + __pyx_t_6 = 127; + __Pyx_INCREF(__pyx_kp_u_Provider); + __pyx_t_5 += 10; + __Pyx_GIVEREF(__pyx_kp_u_Provider); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_Provider); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(((PyObject *)__pyx_ptype_19dependency_injector_9providers_Dependency)); - __Pyx_GIVEREF(((PyObject *)__pyx_ptype_19dependency_injector_9providers_Dependency)); - PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_ptype_19dependency_injector_9providers_Dependency)); - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self)); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 688, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 688, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_getattr); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 688, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_7, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_v_name) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_name); - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 688, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_6; + __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); + __pyx_t_3 = 0; + __Pyx_INCREF(__pyx_kp_u_has_no_attribute); + __pyx_t_5 += 20; + __Pyx_GIVEREF(__pyx_kp_u_has_no_attribute); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u_has_no_attribute); + __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_name, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 688, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_6; + __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3); + __pyx_t_3 = 0; + __Pyx_INCREF(__pyx_kp_u__5); + __pyx_t_5 += 1; + __Pyx_GIVEREF(__pyx_kp_u__5); + PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_kp_u__5); + __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_2, 5, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 688, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(1, 688, __pyx_L1_error) /* "dependency_injector/providers.pyx":683 * return result @@ -15833,7 +15849,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_10Dependency_6__getat __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("dependency_injector.providers.Dependency.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -15843,7 +15859,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_10Dependency_6__getat } /* "dependency_injector/providers.pyx":690 - * return super().__getattr__(name) + * raise AttributeError(f'Provider "{self.__class__.__name__}" has no attribute "{name}"') * * def __str__(self): # <<<<<<<<<<<<<< * """Return string representation of provider. @@ -15893,10 +15909,10 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_10Dependency_8__str__ __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = 127; - __Pyx_INCREF(__pyx_kp_u__5); + __Pyx_INCREF(__pyx_kp_u__6); __pyx_t_2 += 1; - __Pyx_GIVEREF(__pyx_kp_u__5); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u__5); + __Pyx_GIVEREF(__pyx_kp_u__6); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u__6); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 695, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_module); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 695, __pyx_L1_error) @@ -15910,10 +15926,10 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_10Dependency_8__str__ __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4); __pyx_t_4 = 0; - __Pyx_INCREF(__pyx_kp_u__6); + __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_2 += 1; - __Pyx_GIVEREF(__pyx_kp_u__6); - PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__6); + __Pyx_GIVEREF(__pyx_kp_u__7); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__7); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 695, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 695, __pyx_L1_error) @@ -15944,10 +15960,10 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_10Dependency_8__str__ __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = 0; __pyx_t_3 = 127; - __Pyx_INCREF(__pyx_kp_u__7); + __Pyx_INCREF(__pyx_kp_u__8); __pyx_t_2 += 1; - __Pyx_GIVEREF(__pyx_kp_u__7); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u__7); + __Pyx_GIVEREF(__pyx_kp_u__8); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u__8); __pyx_t_1 = __pyx_v_self->__pyx___instance_of; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 696, __pyx_L1_error) @@ -16025,10 +16041,10 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_10Dependency_8__str__ __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5); __pyx_t_5 = 0; - __Pyx_INCREF(__pyx_kp_u__8); + __Pyx_INCREF(__pyx_kp_u__5); __pyx_t_2 += 1; - __Pyx_GIVEREF(__pyx_kp_u__8); - PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_kp_u__8); + __Pyx_GIVEREF(__pyx_kp_u__5); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_kp_u__5); __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_4, 3, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 698, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -16072,7 +16088,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_10Dependency_8__str__ goto __pyx_L0; /* "dependency_injector/providers.pyx":690 - * return super().__getattr__(name) + * raise AttributeError(f'Provider "{self.__class__.__name__}" has no attribute "{name}"') * * def __str__(self): # <<<<<<<<<<<<<< * """Return string representation of provider. @@ -16793,7 +16809,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_10Dependency_11parent __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_t_4, __pyx_kp_u__6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 754, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_t_4, __pyx_kp_u__7); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_name, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 754, __pyx_L1_error) @@ -20360,10 +20376,10 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_21DependenciesContain __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7); __pyx_t_7 = 0; - __Pyx_INCREF(__pyx_kp_u__8); + __Pyx_INCREF(__pyx_kp_u__5); __pyx_t_11 += 1; - __Pyx_GIVEREF(__pyx_kp_u__8); - PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u__8); + __Pyx_GIVEREF(__pyx_kp_u__5); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u__5); __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_2, 3, __pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 955, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -20576,7 +20592,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_21DependenciesContain __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 970, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_t_4, __pyx_kp_u__6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 970, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_t_4, __pyx_kp_u__7); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 970, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_name, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 970, __pyx_L1_error) @@ -22309,7 +22325,7 @@ static int __pyx_pf_19dependency_injector_9providers_8Callable___init__(struct _ PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9); __pyx_t_8 = 0; __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_PyString_Join(__pyx_kp_s__6, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1061, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyString_Join(__pyx_kp_s__7, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1061, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; @@ -26839,7 +26855,7 @@ static int __pyx_pf_19dependency_injector_9providers_9Coroutine___init__(struct PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9); __pyx_t_8 = 0; __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_PyString_Join(__pyx_kp_s__6, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1312, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyString_Join(__pyx_kp_s__7, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1312, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; @@ -30940,7 +30956,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_19ConfigurationOption * segment() if is_provider(segment) else segment for segment in self.__name * ) */ - __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__6, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1462, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__7, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -31104,7 +31120,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_19ConfigurationOption PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__6, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1471, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__7, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; @@ -37367,7 +37383,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_13Configuration_16get __Pyx_DECREF_SET(__pyx_t_2, function); } } - __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_s__6) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_s__6); + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_s__7) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_s__7); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1803, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); @@ -37801,7 +37817,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_13Configuration_18set __Pyx_DECREF_SET(__pyx_t_1, function); } } - __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_kp_s__6) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_kp_s__6); + __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_kp_s__7) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_kp_s__7); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1829, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); @@ -69479,10 +69495,10 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_9Container_10resolve_ __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7); __pyx_t_7 = 0; - __Pyx_INCREF(__pyx_kp_u__8); + __Pyx_INCREF(__pyx_kp_u__5); __pyx_t_11 += 1; - __Pyx_GIVEREF(__pyx_kp_u__8); - PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u__8); + __Pyx_GIVEREF(__pyx_kp_u__5); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u__5); __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_2, 3, __pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 3628, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -69695,7 +69711,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_9Container_11parent_n __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_t_4, __pyx_kp_u__6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 3643, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_t_4, __pyx_kp_u__7); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 3643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_name, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3643, __pyx_L1_error) @@ -71573,7 +71589,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_8Selector_6__str__(st PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyString_Join(__pyx_kp_s__6, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3730, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyString_Join(__pyx_kp_s__7, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_provider, __pyx_t_5) < 0) __PYX_ERR(1, 3730, __pyx_L1_error) @@ -78514,10 +78530,10 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_12MethodCaller_2__rep __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __pyx_t_4 = 0; - __Pyx_INCREF(__pyx_kp_u__7); + __Pyx_INCREF(__pyx_kp_u__8); __pyx_t_2 += 1; - __Pyx_GIVEREF(__pyx_kp_u__7); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u__7); + __Pyx_GIVEREF(__pyx_kp_u__8); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u__8); __pyx_t_4 = __Pyx_PyObject_FormatSimple(((PyObject *)__pyx_v_self->__pyx___provider), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3; @@ -83721,7 +83737,7 @@ static PyObject *__pyx_f_19dependency_injector_9providers_represent_provider(PyO PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyString_Join(__pyx_kp_s__6, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4248, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyString_Join(__pyx_kp_s__7, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_provider, __pyx_t_5) < 0) __PYX_ERR(1, 4248, __pyx_L1_error) @@ -121363,11 +121379,12 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_PositionalInjection, __pyx_k_PositionalInjection, sizeof(__pyx_k_PositionalInjection), 0, 0, 1, 1}, {&__pyx_n_s_ProvidedInstance, __pyx_k_ProvidedInstance, sizeof(__pyx_k_ProvidedInstance), 0, 0, 1, 1}, {&__pyx_n_s_ProvidedInstance___get, __pyx_k_ProvidedInstance___get, sizeof(__pyx_k_ProvidedInstance___get), 0, 0, 1, 1}, - {&__pyx_n_s_Provider, __pyx_k_Provider, sizeof(__pyx_k_Provider), 0, 0, 1, 1}, + {&__pyx_kp_u_Provider, __pyx_k_Provider, sizeof(__pyx_k_Provider), 0, 1, 0, 0}, {&__pyx_kp_s_Provider_0_could_not_be_overridd, __pyx_k_Provider_0_could_not_be_overridd, sizeof(__pyx_k_Provider_0_could_not_be_overridd), 0, 0, 1, 0}, {&__pyx_kp_s_Provider_0_expected_to_get_calla, __pyx_k_Provider_0_expected_to_get_calla, sizeof(__pyx_k_Provider_0_expected_to_get_calla), 0, 0, 1, 0}, {&__pyx_kp_s_Provider_0_expected_to_get_corou, __pyx_k_Provider_0_expected_to_get_corou, sizeof(__pyx_k_Provider_0_expected_to_get_corou), 0, 0, 1, 0}, {&__pyx_kp_s_Provider_0_is_not_overridden, __pyx_k_Provider_0_is_not_overridden, sizeof(__pyx_k_Provider_0_is_not_overridden), 0, 0, 1, 0}, + {&__pyx_n_s_Provider_2, __pyx_k_Provider_2, sizeof(__pyx_k_Provider_2), 0, 0, 1, 1}, {&__pyx_n_s_Provider___get, __pyx_k_Provider___get, sizeof(__pyx_k_Provider___get), 0, 0, 1, 1}, {&__pyx_n_s_Pyx_CFunc_object____object, __pyx_k_Pyx_CFunc_object____object, sizeof(__pyx_k_Pyx_CFunc_object____object), 0, 0, 1, 1}, {&__pyx_n_s_Pyx_CFunc_void____object____ob, __pyx_k_Pyx_CFunc_void____object____ob, sizeof(__pyx_k_Pyx_CFunc_void____object____ob), 0, 0, 1, 1}, @@ -121408,8 +121425,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_u__32, __pyx_k__32, sizeof(__pyx_k__32), 0, 1, 0, 0}, {&__pyx_kp_s__49, __pyx_k__49, sizeof(__pyx_k__49), 0, 0, 1, 0}, {&__pyx_kp_u__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 1, 0, 0}, - {&__pyx_kp_s__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 0, 1, 0}, {&__pyx_kp_u__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 1, 0, 0}, + {&__pyx_kp_s__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 0, 1, 0}, {&__pyx_kp_u__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 1, 0, 0}, {&__pyx_kp_u__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 1, 0, 0}, {&__pyx_kp_u__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 1, 0, 0}, @@ -121515,8 +121532,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_get_name, __pyx_k_get_name, sizeof(__pyx_k_get_name), 0, 0, 1, 1}, {&__pyx_n_s_get_self_name, __pyx_k_get_self_name, sizeof(__pyx_k_get_self_name), 0, 0, 1, 1}, {&__pyx_n_s_get_self_name_locals_genexpr, __pyx_k_get_self_name_locals_genexpr, sizeof(__pyx_k_get_self_name_locals_genexpr), 0, 0, 1, 1}, - {&__pyx_n_s_getattr, __pyx_k_getattr, sizeof(__pyx_k_getattr), 0, 0, 1, 1}, {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, + {&__pyx_kp_u_has_no_attribute, __pyx_k_has_no_attribute, sizeof(__pyx_k_has_no_attribute), 0, 1, 0, 0}, {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1}, {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, {&__pyx_n_s_im_class, __pyx_k_im_class, sizeof(__pyx_k_im_class), 0, 0, 1, 1}, @@ -121740,8 +121757,8 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_DeprecationWarning = __Pyx_GetBuiltinName(__pyx_n_s_DeprecationWarning); if (!__pyx_builtin_DeprecationWarning) __PYX_ERR(1, 325, __pyx_L1_error) __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(1, 385, __pyx_L1_error) __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 608, __pyx_L1_error) + __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(1, 688, __pyx_L1_error) __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) __PYX_ERR(1, 696, __pyx_L1_error) - __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(1, 880, __pyx_L1_error) __pyx_builtin_filter = __Pyx_GetBuiltinName(__pyx_n_s_filter); if (!__pyx_builtin_filter) __PYX_ERR(1, 1193, __pyx_L1_error) __pyx_builtin_IOError = __Pyx_GetBuiltinName(__pyx_n_s_IOError); if (!__pyx_builtin_IOError) __PYX_ERR(1, 1536, __pyx_L1_error) __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 1648, __pyx_L1_error) @@ -122356,7 +122373,7 @@ static int __Pyx_modinit_type_init_code(void) { } #endif if (__Pyx_SetVtable(__pyx_type_19dependency_injector_9providers_Provider.tp_dict, __pyx_vtabptr_19dependency_injector_9providers_Provider) < 0) __PYX_ERR(1, 119, __pyx_L1_error) - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Provider, (PyObject *)&__pyx_type_19dependency_injector_9providers_Provider) < 0) __PYX_ERR(1, 119, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Provider_2, (PyObject *)&__pyx_type_19dependency_injector_9providers_Provider) < 0) __PYX_ERR(1, 119, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_19dependency_injector_9providers_Provider) < 0) __PYX_ERR(1, 119, __pyx_L1_error) __pyx_ptype_19dependency_injector_9providers_Provider = &__pyx_type_19dependency_injector_9providers_Provider; __pyx_vtabptr_19dependency_injector_9providers_Object = &__pyx_vtable_19dependency_injector_9providers_Object; diff --git a/src/dependency_injector/providers.pyx b/src/dependency_injector/providers.pyx index 9b2dcee2..7e44ffd2 100644 --- a/src/dependency_injector/providers.pyx +++ b/src/dependency_injector/providers.pyx @@ -685,7 +685,7 @@ cdef class Dependency(Provider): return getattr(self.__last_overriding, name) elif self.__default is not UNDEFINED: return getattr(self.__default, name) - return super().__getattr__(name) + raise AttributeError(f'Provider "{self.__class__.__name__}" has no attribute "{name}"') def __str__(self): """Return string representation of provider.