Remove and return value for key with optional default (dict-like API). Args: key: The key to remove. *args: Optional default value if key is not found. Returns: The value that was associated with key, or default if key not found. Raises:
(self, key: Any, *args)
| 520 | self._rightmost_leaf_cache = None |
| 521 | |
| 522 | def pop(self, key: Any, *args) -> Any: |
| 523 | """Remove and return value for key with optional default (dict-like API). |
| 524 | |
| 525 | Args: |
| 526 | key: The key to remove. |
| 527 | *args: Optional default value if key is not found. |
| 528 | |
| 529 | Returns: |
| 530 | The value that was associated with key, or default if key not found. |
| 531 | |
| 532 | Raises: |
| 533 | KeyError: If key is not found and no default is provided. |
| 534 | """ |
| 535 | if len(args) > 1: |
| 536 | raise TypeError(f"pop expected at most 2 arguments, got {len(args) + 1}") |
| 537 | |
| 538 | try: |
| 539 | value = self[key] |
| 540 | del self[key] |
| 541 | return value |
| 542 | except KeyError: |
| 543 | if args: |
| 544 | return args[0] |
| 545 | raise |
| 546 | |
| 547 | def popitem(self) -> Tuple[Any, Any]: |
| 548 | """Remove and return an arbitrary (key, value) pair (dict-like API). |
no outgoing calls
no test coverage detected