mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-04 09:57:37 +03:00 
			
		
		
		
	Refactor isinstance() checks
This commit is contained in:
		
							parent
							
								
									3ba65da1ad
								
							
						
					
					
						commit
						1d884b5101
					
				| 
						 | 
				
			
			@ -1692,6 +1692,7 @@ static const char __pyx_k_from_providers[] = "from_providers";
 | 
			
		|||
static const char __pyx_k_init_resources[] = "init_resources";
 | 
			
		||||
static const char __pyx_k_providers_copy[] = "providers_copy";
 | 
			
		||||
static const char __pyx_k_reset_override[] = "reset_override";
 | 
			
		||||
static const char __pyx_k_CHILD_PROVIDERS[] = "CHILD_PROVIDERS";
 | 
			
		||||
static const char __pyx_k_source_provider[] = "source_provider";
 | 
			
		||||
static const char __pyx_k_DynamicContainer[] = "DynamicContainer";
 | 
			
		||||
static const char __pyx_k_copied_container[] = "copied_container";
 | 
			
		||||
| 
						 | 
				
			
			@ -1772,6 +1773,7 @@ static PyObject *__pyx_kp_s_0_can_contain_only_1_instances;
 | 
			
		|||
static PyObject *__pyx_kp_s_Abstract_container;
 | 
			
		||||
static PyObject *__pyx_n_s_AttributeError;
 | 
			
		||||
static PyObject *__pyx_n_s_BaseSingleton;
 | 
			
		||||
static PyObject *__pyx_n_s_CHILD_PROVIDERS;
 | 
			
		||||
static PyObject *__pyx_kp_u_Can_not_resolve_name_for_provide;
 | 
			
		||||
static PyObject *__pyx_n_s_Container;
 | 
			
		||||
static PyObject *__pyx_kp_s_Container_0_could_not_be_overrid;
 | 
			
		||||
| 
						 | 
				
			
			@ -3355,8 +3357,8 @@ static PyObject *__pyx_pf_19dependency_injector_10containers_16DynamicContainer_
 | 
			
		|||
  int __pyx_t_4;
 | 
			
		||||
  int __pyx_t_5;
 | 
			
		||||
  PyObject *__pyx_t_6 = NULL;
 | 
			
		||||
  PyObject *__pyx_t_7 = NULL;
 | 
			
		||||
  int __pyx_t_8;
 | 
			
		||||
  int __pyx_t_7;
 | 
			
		||||
  PyObject *__pyx_t_8 = NULL;
 | 
			
		||||
  int __pyx_lineno = 0;
 | 
			
		||||
  const char *__pyx_filename = NULL;
 | 
			
		||||
  int __pyx_clineno = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -3441,7 +3443,7 @@ static PyObject *__pyx_pf_19dependency_injector_10containers_16DynamicContainer_
 | 
			
		|||
 * 
 | 
			
		||||
 *             self.providers[name] = value             # <<<<<<<<<<<<<<
 | 
			
		||||
 * 
 | 
			
		||||
 *             if isinstance(value, (providers.Dependency, providers.DependenciesContainer, providers.Container)):
 | 
			
		||||
 *             if isinstance(value, providers.CHILD_PROVIDERS):
 | 
			
		||||
 */
 | 
			
		||||
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_providers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error)
 | 
			
		||||
    __Pyx_GOTREF(__pyx_t_2);
 | 
			
		||||
| 
						 | 
				
			
			@ -3451,79 +3453,50 @@ static PyObject *__pyx_pf_19dependency_injector_10containers_16DynamicContainer_
 | 
			
		|||
    /* "dependency_injector/containers.pyx":121
 | 
			
		||||
 *             self.providers[name] = value
 | 
			
		||||
 * 
 | 
			
		||||
 *             if isinstance(value, (providers.Dependency, providers.DependenciesContainer, providers.Container)):             # <<<<<<<<<<<<<<
 | 
			
		||||
 *             if isinstance(value, providers.CHILD_PROVIDERS):             # <<<<<<<<<<<<<<
 | 
			
		||||
 *                 value.assign_parent(self)
 | 
			
		||||
 * 
 | 
			
		||||
 */
 | 
			
		||||
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_providers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error)
 | 
			
		||||
    __Pyx_GOTREF(__pyx_t_2);
 | 
			
		||||
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Dependency); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error)
 | 
			
		||||
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_CHILD_PROVIDERS); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error)
 | 
			
		||||
    __Pyx_GOTREF(__pyx_t_3);
 | 
			
		||||
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 | 
			
		||||
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_providers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error)
 | 
			
		||||
    __Pyx_GOTREF(__pyx_t_2);
 | 
			
		||||
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_DependenciesContainer); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 121, __pyx_L1_error)
 | 
			
		||||
    __Pyx_GOTREF(__pyx_t_6);
 | 
			
		||||
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 | 
			
		||||
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_providers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error)
 | 
			
		||||
    __Pyx_GOTREF(__pyx_t_2);
 | 
			
		||||
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Container); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 121, __pyx_L1_error)
 | 
			
		||||
    __Pyx_GOTREF(__pyx_t_7);
 | 
			
		||||
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 | 
			
		||||
    __pyx_t_5 = PyObject_IsInstance(__pyx_v_value, __pyx_t_3); 
 | 
			
		||||
    __pyx_t_4 = (__pyx_t_5 != 0);
 | 
			
		||||
    if (!__pyx_t_4) {
 | 
			
		||||
    } else {
 | 
			
		||||
      __pyx_t_1 = __pyx_t_4;
 | 
			
		||||
      goto __pyx_L8_bool_binop_done;
 | 
			
		||||
    }
 | 
			
		||||
    __pyx_t_4 = PyObject_IsInstance(__pyx_v_value, __pyx_t_6); 
 | 
			
		||||
    __pyx_t_5 = (__pyx_t_4 != 0);
 | 
			
		||||
    if (!__pyx_t_5) {
 | 
			
		||||
    } else {
 | 
			
		||||
      __pyx_t_1 = __pyx_t_5;
 | 
			
		||||
      goto __pyx_L8_bool_binop_done;
 | 
			
		||||
    }
 | 
			
		||||
    __pyx_t_5 = PyObject_IsInstance(__pyx_v_value, __pyx_t_7); 
 | 
			
		||||
    __pyx_t_4 = (__pyx_t_5 != 0);
 | 
			
		||||
    __pyx_t_1 = __pyx_t_4;
 | 
			
		||||
    __pyx_L8_bool_binop_done:;
 | 
			
		||||
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 | 
			
		||||
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 | 
			
		||||
    __pyx_t_1 = PyObject_IsInstance(__pyx_v_value, __pyx_t_3); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 121, __pyx_L1_error)
 | 
			
		||||
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 | 
			
		||||
    __pyx_t_4 = (__pyx_t_1 != 0);
 | 
			
		||||
    if (__pyx_t_4) {
 | 
			
		||||
    __pyx_t_5 = (__pyx_t_1 != 0);
 | 
			
		||||
    if (__pyx_t_5) {
 | 
			
		||||
 | 
			
		||||
      /* "dependency_injector/containers.pyx":122
 | 
			
		||||
 * 
 | 
			
		||||
 *             if isinstance(value, (providers.Dependency, providers.DependenciesContainer, providers.Container)):
 | 
			
		||||
 *             if isinstance(value, providers.CHILD_PROVIDERS):
 | 
			
		||||
 *                 value.assign_parent(self)             # <<<<<<<<<<<<<<
 | 
			
		||||
 * 
 | 
			
		||||
 *         super(DynamicContainer, self).__setattr__(name, value)
 | 
			
		||||
 */
 | 
			
		||||
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_assign_parent); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 122, __pyx_L1_error)
 | 
			
		||||
      __Pyx_GOTREF(__pyx_t_6);
 | 
			
		||||
      __pyx_t_7 = NULL;
 | 
			
		||||
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
 | 
			
		||||
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
 | 
			
		||||
        if (likely(__pyx_t_7)) {
 | 
			
		||||
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
 | 
			
		||||
          __Pyx_INCREF(__pyx_t_7);
 | 
			
		||||
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_assign_parent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 122, __pyx_L1_error)
 | 
			
		||||
      __Pyx_GOTREF(__pyx_t_2);
 | 
			
		||||
      __pyx_t_6 = NULL;
 | 
			
		||||
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
 | 
			
		||||
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
 | 
			
		||||
        if (likely(__pyx_t_6)) {
 | 
			
		||||
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
 | 
			
		||||
          __Pyx_INCREF(__pyx_t_6);
 | 
			
		||||
          __Pyx_INCREF(function);
 | 
			
		||||
          __Pyx_DECREF_SET(__pyx_t_6, function);
 | 
			
		||||
          __Pyx_DECREF_SET(__pyx_t_2, function);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_v_self) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_self);
 | 
			
		||||
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
 | 
			
		||||
      __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_v_self) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self);
 | 
			
		||||
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
 | 
			
		||||
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error)
 | 
			
		||||
      __Pyx_GOTREF(__pyx_t_3);
 | 
			
		||||
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 | 
			
		||||
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 | 
			
		||||
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 | 
			
		||||
 | 
			
		||||
      /* "dependency_injector/containers.pyx":121
 | 
			
		||||
 *             self.providers[name] = value
 | 
			
		||||
 * 
 | 
			
		||||
 *             if isinstance(value, (providers.Dependency, providers.DependenciesContainer, providers.Container)):             # <<<<<<<<<<<<<<
 | 
			
		||||
 *             if isinstance(value, providers.CHILD_PROVIDERS):             # <<<<<<<<<<<<<<
 | 
			
		||||
 *                 value.assign_parent(self)
 | 
			
		||||
 * 
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			@ -3545,67 +3518,67 @@ static PyObject *__pyx_pf_19dependency_injector_10containers_16DynamicContainer_
 | 
			
		|||
 * 
 | 
			
		||||
 *     def __delattr__(self, str name):
 | 
			
		||||
 */
 | 
			
		||||
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_DynamicContainer); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_DynamicContainer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
  __Pyx_GOTREF(__pyx_t_2);
 | 
			
		||||
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
  __Pyx_GOTREF(__pyx_t_6);
 | 
			
		||||
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
  __Pyx_GOTREF(__pyx_t_7);
 | 
			
		||||
  __Pyx_GIVEREF(__pyx_t_6);
 | 
			
		||||
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
 | 
			
		||||
  __Pyx_GIVEREF(__pyx_t_2);
 | 
			
		||||
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
 | 
			
		||||
  __Pyx_INCREF(__pyx_v_self);
 | 
			
		||||
  __Pyx_GIVEREF(__pyx_v_self);
 | 
			
		||||
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_self);
 | 
			
		||||
  __pyx_t_6 = 0;
 | 
			
		||||
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
  __Pyx_GOTREF(__pyx_t_6);
 | 
			
		||||
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 | 
			
		||||
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_setattr); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
  __Pyx_GOTREF(__pyx_t_7);
 | 
			
		||||
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_self);
 | 
			
		||||
  __pyx_t_2 = 0;
 | 
			
		||||
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
  __Pyx_GOTREF(__pyx_t_2);
 | 
			
		||||
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 | 
			
		||||
  __pyx_t_6 = NULL;
 | 
			
		||||
  __pyx_t_8 = 0;
 | 
			
		||||
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
 | 
			
		||||
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
 | 
			
		||||
    if (likely(__pyx_t_6)) {
 | 
			
		||||
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
 | 
			
		||||
      __Pyx_INCREF(__pyx_t_6);
 | 
			
		||||
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_setattr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
  __Pyx_GOTREF(__pyx_t_6);
 | 
			
		||||
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 | 
			
		||||
  __pyx_t_2 = NULL;
 | 
			
		||||
  __pyx_t_7 = 0;
 | 
			
		||||
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
 | 
			
		||||
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
 | 
			
		||||
    if (likely(__pyx_t_2)) {
 | 
			
		||||
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
 | 
			
		||||
      __Pyx_INCREF(__pyx_t_2);
 | 
			
		||||
      __Pyx_INCREF(function);
 | 
			
		||||
      __Pyx_DECREF_SET(__pyx_t_7, function);
 | 
			
		||||
      __pyx_t_8 = 1;
 | 
			
		||||
      __Pyx_DECREF_SET(__pyx_t_6, function);
 | 
			
		||||
      __pyx_t_7 = 1;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  #if CYTHON_FAST_PYCALL
 | 
			
		||||
  if (PyFunction_Check(__pyx_t_7)) {
 | 
			
		||||
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_name, __pyx_v_value};
 | 
			
		||||
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
 | 
			
		||||
  if (PyFunction_Check(__pyx_t_6)) {
 | 
			
		||||
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_name, __pyx_v_value};
 | 
			
		||||
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
 | 
			
		||||
    __Pyx_GOTREF(__pyx_t_3);
 | 
			
		||||
  } else
 | 
			
		||||
  #endif
 | 
			
		||||
  #if CYTHON_FAST_PYCCALL
 | 
			
		||||
  if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
 | 
			
		||||
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_name, __pyx_v_value};
 | 
			
		||||
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
 | 
			
		||||
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
 | 
			
		||||
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_name, __pyx_v_value};
 | 
			
		||||
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
 | 
			
		||||
    __Pyx_GOTREF(__pyx_t_3);
 | 
			
		||||
  } else
 | 
			
		||||
  #endif
 | 
			
		||||
  {
 | 
			
		||||
    __pyx_t_2 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
    __Pyx_GOTREF(__pyx_t_2);
 | 
			
		||||
    if (__pyx_t_6) {
 | 
			
		||||
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __pyx_t_6 = NULL;
 | 
			
		||||
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
    __Pyx_GOTREF(__pyx_t_8);
 | 
			
		||||
    if (__pyx_t_2) {
 | 
			
		||||
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL;
 | 
			
		||||
    }
 | 
			
		||||
    __Pyx_INCREF(__pyx_v_name);
 | 
			
		||||
    __Pyx_GIVEREF(__pyx_v_name);
 | 
			
		||||
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_8, __pyx_v_name);
 | 
			
		||||
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_name);
 | 
			
		||||
    __Pyx_INCREF(__pyx_v_value);
 | 
			
		||||
    __Pyx_GIVEREF(__pyx_v_value);
 | 
			
		||||
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_8, __pyx_v_value);
 | 
			
		||||
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value);
 | 
			
		||||
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error)
 | 
			
		||||
    __Pyx_GOTREF(__pyx_t_3);
 | 
			
		||||
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 | 
			
		||||
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 | 
			
		||||
  }
 | 
			
		||||
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 | 
			
		||||
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 | 
			
		||||
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 | 
			
		||||
 | 
			
		||||
  /* "dependency_injector/containers.pyx":100
 | 
			
		||||
| 
						 | 
				
			
			@ -3623,7 +3596,7 @@ static PyObject *__pyx_pf_19dependency_injector_10containers_16DynamicContainer_
 | 
			
		|||
  __Pyx_XDECREF(__pyx_t_2);
 | 
			
		||||
  __Pyx_XDECREF(__pyx_t_3);
 | 
			
		||||
  __Pyx_XDECREF(__pyx_t_6);
 | 
			
		||||
  __Pyx_XDECREF(__pyx_t_7);
 | 
			
		||||
  __Pyx_XDECREF(__pyx_t_8);
 | 
			
		||||
  __Pyx_AddTraceback("dependency_injector.containers.DynamicContainer.__setattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
 | 
			
		||||
  __pyx_r = NULL;
 | 
			
		||||
  __pyx_L0:;
 | 
			
		||||
| 
						 | 
				
			
			@ -9455,7 +9428,6 @@ static PyObject *__pyx_pf_19dependency_injector_10containers_29DeclarativeContai
 | 
			
		|||
  PyObject *(*__pyx_t_9)(PyObject *);
 | 
			
		||||
  int __pyx_t_10;
 | 
			
		||||
  int __pyx_t_11;
 | 
			
		||||
  int __pyx_t_12;
 | 
			
		||||
  int __pyx_lineno = 0;
 | 
			
		||||
  const char *__pyx_filename = NULL;
 | 
			
		||||
  int __pyx_clineno = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -9477,7 +9449,7 @@ static PyObject *__pyx_pf_19dependency_injector_10containers_29DeclarativeContai
 | 
			
		|||
 *         return {
 | 
			
		||||
 *             name: provider
 | 
			
		||||
 *             for name, provider in cls.providers.items()             # <<<<<<<<<<<<<<
 | 
			
		||||
 *             if isinstance(provider, (providers.Dependency, providers.DependenciesContainer))
 | 
			
		||||
 *             if isinstance(provider, providers.CHILD_PROVIDERS)
 | 
			
		||||
 *         }
 | 
			
		||||
 */
 | 
			
		||||
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_cls, __pyx_n_s_providers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 427, __pyx_L5_error)
 | 
			
		||||
| 
						 | 
				
			
			@ -9594,32 +9566,16 @@ static PyObject *__pyx_pf_19dependency_injector_10containers_29DeclarativeContai
 | 
			
		|||
      /* "dependency_injector/containers.pyx":428
 | 
			
		||||
 *             name: provider
 | 
			
		||||
 *             for name, provider in cls.providers.items()
 | 
			
		||||
 *             if isinstance(provider, (providers.Dependency, providers.DependenciesContainer))             # <<<<<<<<<<<<<<
 | 
			
		||||
 *             if isinstance(provider, providers.CHILD_PROVIDERS)             # <<<<<<<<<<<<<<
 | 
			
		||||
 *         }
 | 
			
		||||
 * 
 | 
			
		||||
 */
 | 
			
		||||
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_providers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 428, __pyx_L5_error)
 | 
			
		||||
      __Pyx_GOTREF(__pyx_t_2);
 | 
			
		||||
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Dependency); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 428, __pyx_L5_error)
 | 
			
		||||
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_CHILD_PROVIDERS); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 428, __pyx_L5_error)
 | 
			
		||||
      __Pyx_GOTREF(__pyx_t_7);
 | 
			
		||||
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 | 
			
		||||
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_providers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 428, __pyx_L5_error)
 | 
			
		||||
      __Pyx_GOTREF(__pyx_t_2);
 | 
			
		||||
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_DependenciesContainer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 428, __pyx_L5_error)
 | 
			
		||||
      __Pyx_GOTREF(__pyx_t_3);
 | 
			
		||||
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 | 
			
		||||
      __pyx_t_11 = PyObject_IsInstance(__pyx_8genexpr4__pyx_v_provider, __pyx_t_7); 
 | 
			
		||||
      __pyx_t_12 = (__pyx_t_11 != 0);
 | 
			
		||||
      if (!__pyx_t_12) {
 | 
			
		||||
      } else {
 | 
			
		||||
        __pyx_t_10 = __pyx_t_12;
 | 
			
		||||
        goto __pyx_L11_bool_binop_done;
 | 
			
		||||
      }
 | 
			
		||||
      __pyx_t_12 = PyObject_IsInstance(__pyx_8genexpr4__pyx_v_provider, __pyx_t_3); 
 | 
			
		||||
      __pyx_t_11 = (__pyx_t_12 != 0);
 | 
			
		||||
      __pyx_t_10 = __pyx_t_11;
 | 
			
		||||
      __pyx_L11_bool_binop_done:;
 | 
			
		||||
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 | 
			
		||||
      __pyx_t_10 = PyObject_IsInstance(__pyx_8genexpr4__pyx_v_provider, __pyx_t_7); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 428, __pyx_L5_error)
 | 
			
		||||
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 | 
			
		||||
      __pyx_t_11 = (__pyx_t_10 != 0);
 | 
			
		||||
      if (__pyx_t_11) {
 | 
			
		||||
| 
						 | 
				
			
			@ -9629,14 +9585,14 @@ static PyObject *__pyx_pf_19dependency_injector_10containers_29DeclarativeContai
 | 
			
		|||
 *         return {
 | 
			
		||||
 *             name: provider             # <<<<<<<<<<<<<<
 | 
			
		||||
 *             for name, provider in cls.providers.items()
 | 
			
		||||
 *             if isinstance(provider, (providers.Dependency, providers.DependenciesContainer))
 | 
			
		||||
 *             if isinstance(provider, providers.CHILD_PROVIDERS)
 | 
			
		||||
 */
 | 
			
		||||
        if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_8genexpr4__pyx_v_name, (PyObject*)__pyx_8genexpr4__pyx_v_provider))) __PYX_ERR(0, 426, __pyx_L5_error)
 | 
			
		||||
 | 
			
		||||
        /* "dependency_injector/containers.pyx":428
 | 
			
		||||
 *             name: provider
 | 
			
		||||
 *             for name, provider in cls.providers.items()
 | 
			
		||||
 *             if isinstance(provider, (providers.Dependency, providers.DependenciesContainer))             # <<<<<<<<<<<<<<
 | 
			
		||||
 *             if isinstance(provider, providers.CHILD_PROVIDERS)             # <<<<<<<<<<<<<<
 | 
			
		||||
 *         }
 | 
			
		||||
 * 
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			@ -9646,19 +9602,19 @@ static PyObject *__pyx_pf_19dependency_injector_10containers_29DeclarativeContai
 | 
			
		|||
 *         return {
 | 
			
		||||
 *             name: provider
 | 
			
		||||
 *             for name, provider in cls.providers.items()             # <<<<<<<<<<<<<<
 | 
			
		||||
 *             if isinstance(provider, (providers.Dependency, providers.DependenciesContainer))
 | 
			
		||||
 *             if isinstance(provider, providers.CHILD_PROVIDERS)
 | 
			
		||||
 *         }
 | 
			
		||||
 */
 | 
			
		||||
    }
 | 
			
		||||
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 | 
			
		||||
    __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_name); __pyx_8genexpr4__pyx_v_name = 0;
 | 
			
		||||
    __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_provider); __pyx_8genexpr4__pyx_v_provider = 0;
 | 
			
		||||
    goto __pyx_L13_exit_scope;
 | 
			
		||||
    goto __pyx_L11_exit_scope;
 | 
			
		||||
    __pyx_L5_error:;
 | 
			
		||||
    __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_name); __pyx_8genexpr4__pyx_v_name = 0;
 | 
			
		||||
    __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_provider); __pyx_8genexpr4__pyx_v_provider = 0;
 | 
			
		||||
    goto __pyx_L1_error;
 | 
			
		||||
    __pyx_L13_exit_scope:;
 | 
			
		||||
    __pyx_L11_exit_scope:;
 | 
			
		||||
  } /* exit inner scope */
 | 
			
		||||
  __pyx_r = __pyx_t_1;
 | 
			
		||||
  __pyx_t_1 = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -13972,6 +13928,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
 | 
			
		|||
  {&__pyx_kp_s_Abstract_container, __pyx_k_Abstract_container, sizeof(__pyx_k_Abstract_container), 0, 0, 1, 0},
 | 
			
		||||
  {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
 | 
			
		||||
  {&__pyx_n_s_BaseSingleton, __pyx_k_BaseSingleton, sizeof(__pyx_k_BaseSingleton), 0, 0, 1, 1},
 | 
			
		||||
  {&__pyx_n_s_CHILD_PROVIDERS, __pyx_k_CHILD_PROVIDERS, sizeof(__pyx_k_CHILD_PROVIDERS), 0, 0, 1, 1},
 | 
			
		||||
  {&__pyx_kp_u_Can_not_resolve_name_for_provide, __pyx_k_Can_not_resolve_name_for_provide, sizeof(__pyx_k_Can_not_resolve_name_for_provide), 0, 1, 0, 0},
 | 
			
		||||
  {&__pyx_n_s_Container, __pyx_k_Container, sizeof(__pyx_k_Container), 0, 0, 1, 1},
 | 
			
		||||
  {&__pyx_kp_s_Container_0_could_not_be_overrid, __pyx_k_Container_0_could_not_be_overrid, sizeof(__pyx_k_Container_0_could_not_be_overrid), 0, 0, 1, 0},
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -118,7 +118,7 @@ class DynamicContainer(Container):
 | 
			
		|||
 | 
			
		||||
            self.providers[name] = value
 | 
			
		||||
 | 
			
		||||
            if isinstance(value, (providers.Dependency, providers.DependenciesContainer, providers.Container)):
 | 
			
		||||
            if isinstance(value, providers.CHILD_PROVIDERS):
 | 
			
		||||
                value.assign_parent(self)
 | 
			
		||||
 | 
			
		||||
        super(DynamicContainer, self).__setattr__(name, value)
 | 
			
		||||
| 
						 | 
				
			
			@ -425,7 +425,7 @@ class DeclarativeContainerMetaClass(type):
 | 
			
		|||
        return {
 | 
			
		||||
            name: provider
 | 
			
		||||
            for name, provider in cls.providers.items()
 | 
			
		||||
            if isinstance(provider, (providers.Dependency, providers.DependenciesContainer))
 | 
			
		||||
            if isinstance(provider, providers.CHILD_PROVIDERS)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    def traverse(cls, types=None):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -437,3 +437,6 @@ if pydantic:
 | 
			
		|||
    PydanticSettings = pydantic.BaseSettings
 | 
			
		||||
else:
 | 
			
		||||
    PydanticSettings = Any
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
CHILD_PROVIDERS: Tuple[Provider]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -834,7 +834,7 @@ cdef class DependenciesContainer(Object):
 | 
			
		|||
    def __init__(self, **dependencies):
 | 
			
		||||
        """Initializer."""
 | 
			
		||||
        for provider in dependencies.values():
 | 
			
		||||
            if isinstance(provider, (Dependency, DependenciesContainer, Container)):
 | 
			
		||||
            if isinstance(provider, CHILD_PROVIDERS):
 | 
			
		||||
                provider.assign_parent(self)
 | 
			
		||||
 | 
			
		||||
        self.__providers = dependencies
 | 
			
		||||
| 
						 | 
				
			
			@ -4160,6 +4160,9 @@ cpdef tuple parse_named_injections(dict kwargs):
 | 
			
		|||
    return tuple(injections)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
CHILD_PROVIDERS = (Dependency, DependenciesContainer, Container)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
cpdef bint is_provider(object instance):
 | 
			
		||||
    """Check if instance is provider instance.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user