| 3426 | self._expunge_states([state] + [st_ for o, m, st_, dct_ in cascaded]) |
| 3427 | |
| 3428 | def _expunge_states( |
| 3429 | self, states: Iterable[InstanceState[Any]], to_transient: bool = False |
| 3430 | ) -> None: |
| 3431 | for state in states: |
| 3432 | if state in self._new: |
| 3433 | self._new.pop(state) |
| 3434 | elif self.identity_map.contains_state(state): |
| 3435 | self.identity_map.safe_discard(state) |
| 3436 | self._deleted.pop(state, None) |
| 3437 | elif self._transaction: |
| 3438 | # state is "detached" from being deleted, but still present |
| 3439 | # in the transaction snapshot |
| 3440 | self._transaction._deleted.pop(state, None) |
| 3441 | statelib.InstanceState._detach_states( |
| 3442 | states, self, to_transient=to_transient |
| 3443 | ) |
| 3444 | |
| 3445 | def _register_persistent(self, states: Set[InstanceState[Any]]) -> None: |
| 3446 | """Register all persistent objects from a flush. |