These four lines should instead be the simpler single line

    search_params = data.pop('q', {})