def update_types(patches, domain, data_type_id, data_tag, is_global, transaction):
    data_type = FixtureDataType.get(data_type_id)
    fields_patches = deepcopy(patches)
    assert(data_type.doc_type == FixtureDataType._doc_type)
    assert(data_type.domain == domain)
    old_fields = data_type.fields
    new_fixture_fields = []
    setattr(data_type, "tag", data_tag)
    setattr(data_type, "is_global", is_global)
    for old_field in old_fields:
        patch = fields_patches.pop(old_field.field_name, {})
        if not any(patch):
            new_fixture_fields.append(old_field)
        if "update" in patch:
            setattr(old_field, "field_name", patch["update"])
            new_fixture_fields.append(old_field)
        if "remove" in patch:
            continue
    new_fields = fields_patches.keys()
    for new_field_name in new_fields:
        patch = fields_patches.pop(new_field_name)
        if patch in "is_new":
            new_fixture_fields.append(FixtureTypeField(
                field_name=new_field_name,
                properties=[]
            ))
    setattr(data_type, "fields", new_fixture_fields)
    transaction.save(data_type)
    return data_type
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/fixtures/views.py/update_types/swapped operands of `in`