'Change the topic subscription.
Arguments:
topics (list of str): topics for subscription
Raises:
IllegalStateErrror: if assign_from_user has been used already
TypeError: if a non-str topic is given'

def change_subscription(self, topics):

    if self._user_assignment:
        raise IllegalStateError(self._SUBSCRIPTION_EXCEPTION_MESSAGE)
    if isinstance(topics, six.string_types):
        topics = [topics]
    if (self.subscription == set(topics)):
        log.warning('subscription    unchanged    by    change_subscription(%s)', topics)
        return
    if any(((not isinstance(t, six.string_types)) for t in topics)):
        raise TypeError('All    topics    must    be    strings')
    log.info('Updating    subscribed    topics    to:    %s', topics)
    self.subscription = set(topics)
    self._group_subscription.update(topics)
    self.needs_partition_assignment = True
    for tp in set(self.assignment.keys()):
        if (tp.topic not in self.subscription):
            del self.assignment[tp]
