def _validate_tag_sets(tag_sets):
    if tag_sets is None:
        return tag_sets

    if not isinstance(tag_sets, list):
        raise TypeError((
            "Tag sets %r invalid, must be a list") % (tag_sets,))
    if len(tag_sets) == 0:
        raise ValueError((
            "Tag sets %r invalid, must be None or contain at least one set of"
            " tags") % (tag_sets,))

    for tags in tag_sets:
        if not isinstance(tags, Mapping):
            raise TypeError(
                "Tag set %r invalid, must be an instance of dict, "
                "bson.son.SON or other type that inherits from "
                "collection.Mapping" % (tags,))

    return tag_sets
Check that the value is of the expected type.
dataset/ETHPy150Open mongodb/mongo-python-driver/pymongo/read_preferences.py/_validate_tag_sets--crossover with--dataset/ETHPy150Open google/grr/grr/lib/aff4.py/AFF4Object._CheckAttribute