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