(self, dependency_candidates)
updates self._dependency_store to reflect instantiated dependencies, if any.
updates self._dependency_store to reflect instantiated dependencies, if any.
updates self . _dependency_store to reflect instantiated dependencies if any .
def _update_dependencies(self, dependency_candidates):
        """updates self._dependency_store to reflect instantiated dependencies, if any."""
        if self._dependency_store:
            potentials = []

            # in case the candidate is an instance of a desired base class
            # (e.g. Project for self._dependency_store = {'UnifiedJobTemplate': None})
            # we try each of its base classes until a match is found
            base_lookup = {}
            for candidate in dependency_candidates:
                for cls_type in inspect.getmro(candidate[0].__class__):
                    if cls_type in self._dependency_store:
                        base_lookup[candidate[0]] = cls_type
                        potentials.append(candidate)
                        break
            second_pass = []
            for candidate, claimed in potentials:
                if claimed:
                    self._dependency_store[base_lookup[candidate]] = candidate
                else:
                    second_pass.append(candidate)
            # Technical Debt: We need to iron out the expected behavior of multiple instances
            # of unclaimed types. Right now the last one in potentials is marked as a dependency.
            second_pass.reverse()  # for the last one in the list to be marked we need to reverse.
            for candidate in second_pass:
                if not self._dependency_store[base_lookup[candidate]]:
                    self._dependency_store[base_lookup[candidate]] = candidate
def _update_dependencies ( self , dependency_candidates ) : if self . _dependency_store : potentials = [ ] # in case the candidate is an instance of a desired base class # (e.g. Project for self._dependency_store = {'UnifiedJobTemplate': None}) # we try each of its base classes until a match is found base_lookup = { } for candidate in dependency_candidates : for cls_type in inspect . getmro ( candidate [ 0 ] . __class__ ) : if cls_type in self . _dependency_store : base_lookup [ candidate [ 0 ] ] = cls_type potentials . append ( candidate ) break second_pass = [ ] for candidate , claimed in potentials : if claimed : self . _dependency_store [ base_lookup [ candidate ] ] = candidate else : second_pass . append ( candidate ) # Technical Debt: We need to iron out the expected behavior of multiple instances # of unclaimed types. Right now the last one in potentials is marked as a dependency. second_pass . reverse ( ) # for the last one in the list to be marked we need to reverse. for candidate in second_pass : if not self . _dependency_store [ base_lookup [ candidate ] ] : self . _dependency_store [ base_lookup [ candidate ] ] = candidate