MCPcopy Index your code
hub / github.com/couchbase/couchbase-python-client / remove_at

Method remove_at

acouchbase/datastructures.py:252–278  ·  view source on GitHub ↗

Remove the element at a specific index from a list. :param index: The index to remove :param kwargs: Arguments to :meth:`mutate_in` :return: :class:`OperationResult` :raise: :exc:`IndexError` if the index does not exist :raise: :cb_exc:`DocumentNotFo

(self, index: int)

Source from the content-addressed store, hash-verified

250 raise InvalidArgumentException(message=f'Index: {index} is out of range.') from None
251
252 async def remove_at(self, index: int) -> None:
253 """
254 Remove the element at a specific index from a list.
255
256 :param index: The index to remove
257 :param kwargs: Arguments to :meth:`mutate_in`
258 :return: :class:`OperationResult`
259 :raise: :exc:`IndexError` if the index does not exist
260 :raise: :cb_exc:`DocumentNotFoundException` if the list does not exist
261 """
262 op_type = DatastructureOperationType.ListRemoveAt
263 async with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler:
264 ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict())
265 kv_op_type = KeyValueOperationType.MutateIn
266 async with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler:
267 try:
268 op = remove(f'[{index}]')
269 req = self._impl.request_builder.build_mutate_in_request(self._key,
270 (op,),
271 obs_handler,
272 parent_span=ds_obs_handler.wrapped_span)
273 await self._execute_op(self._impl.mutate_in,
274 req,
275 obs_handler,
276 ds_obs_handler.wrapped_span)
277 except PathNotFoundException:
278 raise InvalidArgumentException(message=f'Index: {index} is out of range.') from None
279
280 async def size(self) -> int:
281 """

Callers 3

test_listMethod · 0.45
test_kv_ds_listMethod · 0.45
test_kv_ds_listMethod · 0.45

Calls 7

_execute_opMethod · 0.95
removeFunction · 0.90
get_details_as_dictMethod · 0.80
create_kv_spanMethod · 0.45

Tested by 3

test_listMethod · 0.36
test_kv_ds_listMethod · 0.36
test_kv_ds_listMethod · 0.36