``isinstance()`` accepts a tuple for the second argument, so this could just be ``isinstance(rule, six.string_types)``.