def get(self, thing: type):
        """
        Get an instance of some type.
        """
        if thing in self.instances:
            return self.instances[thing]

        if thing in self.factories:
            fact = self.factories[thing]
            ret = self.get(fact)
            if hasattr(fact, '__di__') and fact.__di__['singleton']:
                self.instances[thing] = ret
            return ret

        if inspect.isclass(thing):
            return self._call_class_init(thing)
        elif callable(thing):
            return self.call(thing)

        raise DiayException('cannot resolve: %r' % thing)
def get ( self , thing : type ) : if thing in self . instances : return self . instances [ thing ] if thing in self . factories : fact = self . factories [ thing ] ret = self . get ( fact ) if hasattr ( fact , '__di__' ) and fact . __di__ [ 'singleton' ] : self . instances [ thing ] = ret return ret if inspect . isclass ( thing ) : return self . _call_class_init ( thing ) elif callable ( thing ) : return self . call ( thing ) raise DiayException ( 'cannot resolve: %r' % thing )
Get an instance of some type.