Set an instance of a thing.

def set_instance(self, thing: type, value, overwrite=False):
        """
        Set an instance of a thing.
        """
        if thing in self.instances and not overwrite:
            raise DiayException('instance for %r already exists' % thing)
        self.instances[thing] = value