|
23 | 23 | UnknownAttributeError,
|
24 | 24 | IntegrityError,
|
25 | 25 | )
|
| 26 | +from typing import Union |
26 | 27 | from .version import __version__ as version
|
27 | 28 |
|
28 | 29 | logger = logging.getLogger(__name__.split(".")[0])
|
@@ -460,15 +461,30 @@ def delete_quick(self, get_count=False):
|
460 | 461 | self._log(query[:255])
|
461 | 462 | return count
|
462 | 463 |
|
463 |
| - def delete(self, transaction=True, safemode=None, force_parts=False): |
| 464 | + def delete( |
| 465 | + self, |
| 466 | + transaction: bool = True, |
| 467 | + safemode: Union[bool, None] = None, |
| 468 | + force_parts: bool = False, |
| 469 | + ) -> int: |
464 | 470 | """
|
465 | 471 | Deletes the contents of the table and its dependent tables, recursively.
|
466 | 472 |
|
467 |
| - :param transaction: if True, use the entire delete becomes an atomic transaction. This is the default and |
468 |
| - recommended behavior. Set to False if this delete is nested within another transaction. |
469 |
| - :param safemode: If True, prohibit nested transactions and prompt to confirm. Default is dj.config['safemode']. |
470 |
| - :param force_parts: Delete from parts even when not deleting from their masters. |
471 |
| - :return: number of deleted rows (excluding those from dependent tables) |
| 473 | + Args: |
| 474 | + transaction: If `True`, use of the entire delete becomes an atomic transaction. |
| 475 | + This is the default and recommended behavior. Set to `False` if this delete is |
| 476 | + nested within another transaction. |
| 477 | + safemode: If `True`, prohibit nested transactions and prompt to confirm. Default |
| 478 | + is `dj.config['safemode']`. |
| 479 | + force_parts: Delete from parts even when not deleting from their masters. |
| 480 | +
|
| 481 | + Returns: |
| 482 | + Number of deleted rows (excluding those from dependent tables). |
| 483 | +
|
| 484 | + Raises: |
| 485 | + DataJointError: Delete exceeds maximum number of delete attempts. |
| 486 | + DataJointError: When deleting within an existing transaction. |
| 487 | + DataJointError: Deleting a part table before its master. |
472 | 488 | """
|
473 | 489 | deleted = set()
|
474 | 490 |
|
|
0 commit comments