MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / remove_at

Method remove_at

couchbase/datastructures.py:245–271  ·  view source on GitHub ↗

Removes an item at a specific index from the list. Args: index (int): The index to remove. Raises: :class:`~couchbase.exceptions.InvalidArgumentException`: If the index is out of range.

(self, index: int)

Source from the content-addressed store, hash-verified

243 raise InvalidArgumentException(message=f'Index: {index} is out of range.') from None
244
245 def remove_at(self, index: int) -> None:
246 """Removes an item at a specific index from the list.
247
248 Args:
249 index (int): The index to remove.
250
251 Raises:
252 :class:`~couchbase.exceptions.InvalidArgumentException`: If the index is out of range.
253
254 """
255 op_type = DatastructureOperationType.ListRemoveAt
256 with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler:
257 ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict())
258 kv_op_type = KeyValueOperationType.MutateIn
259 with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler:
260 try:
261 op = remove(f'[{index}]')
262 req = self._impl.request_builder.build_mutate_in_request(self._key,
263 (op,),
264 obs_handler,
265 parent_span=ds_obs_handler.wrapped_span)
266 self._execute_op(self._impl.mutate_in,
267 req,
268 obs_handler,
269 ds_obs_handler.wrapped_span)
270 except PathNotFoundException:
271 raise InvalidArgumentException(message=f'Index: {index} is out of range.') from None
272
273 def size(self) -> int:
274 """Returns the number of items in the list.

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