from typing import Any
from typing import Optional

from . import attributes as attributes
from .. import event as event
from .. import util as util
from ..util import topological as topological

def track_cascade_events(descriptor: Any, prop: Any): ...

class UOWTransaction:
    session: Any = ...
    attributes: Any = ...
    deps: Any = ...
    mappers: Any = ...
    presort_actions: Any = ...
    postsort_actions: Any = ...
    dependencies: Any = ...
    states: Any = ...
    post_update_states: Any = ...
    def __init__(self, session: Any): ...
    @property
    def has_work(self): ...
    def was_already_deleted(self, state: Any): ...
    def is_deleted(self, state: Any): ...
    def memo(self, key: Any, callable_: Any): ...
    def remove_state_actions(self, state: Any) -> None: ...
    def get_attribute_history(
        self, state: Any, key: Any, passive: Any = ...
    ): ...
    def has_dep(self, processor: Any): ...
    def register_preprocessor(
        self, processor: Any, fromparent: Any
    ) -> None: ...
    def register_object(
        self,
        state: Any,
        isdelete: bool = ...,
        listonly: bool = ...,
        cancel_delete: bool = ...,
        operation: Optional[Any] = ...,
        prop: Optional[Any] = ...,
    ): ...
    def register_post_update(
        self, state: Any, post_update_cols: Any
    ) -> None: ...
    def filter_states_for_dep(self, dep: Any, states: Any): ...
    def states_for_mapper_hierarchy(
        self, mapper: Any, isdelete: Any, listonly: Any
    ) -> None: ...
    def execute(self): ...
    def finalize_flush_changes(self) -> None: ...

class IterateMappersMixin: ...

class Preprocess(IterateMappersMixin):
    dependency_processor: Any = ...
    fromparent: Any = ...
    processed: Any = ...
    setup_flush_actions: bool = ...
    def __init__(self, dependency_processor: Any, fromparent: Any) -> None: ...
    def execute(self, uow: Any): ...

class PostSortRec:
    def __new__(cls, uow: Any, *args: Any): ...
    def execute_aggregate(self, uow: Any, recs: Any) -> None: ...

class ProcessAll(IterateMappersMixin, PostSortRec):
    dependency_processor: Any = ...
    sort_key: Any = ...
    isdelete: Any = ...
    fromparent: Any = ...
    def __init__(
        self,
        uow: Any,
        dependency_processor: Any,
        isdelete: Any,
        fromparent: Any,
    ) -> None: ...
    def execute(self, uow: Any) -> None: ...
    def per_state_flush_actions(self, uow: Any): ...

class PostUpdateAll(PostSortRec):
    mapper: Any = ...
    isdelete: Any = ...
    sort_key: Any = ...
    def __init__(self, uow: Any, mapper: Any, isdelete: Any) -> None: ...
    def execute(self, uow: Any) -> None: ...

class SaveUpdateAll(PostSortRec):
    mapper: Any = ...
    sort_key: Any = ...
    def __init__(self, uow: Any, mapper: Any) -> None: ...
    def execute(self, uow: Any) -> None: ...
    def per_state_flush_actions(self, uow: Any) -> None: ...

class DeleteAll(PostSortRec):
    mapper: Any = ...
    sort_key: Any = ...
    def __init__(self, uow: Any, mapper: Any) -> None: ...
    def execute(self, uow: Any) -> None: ...
    def per_state_flush_actions(self, uow: Any) -> None: ...

class ProcessState(PostSortRec):
    dependency_processor: Any = ...
    sort_key: Any = ...
    isdelete: Any = ...
    state: Any = ...
    def __init__(
        self, uow: Any, dependency_processor: Any, isdelete: Any, state: Any
    ) -> None: ...
    def execute_aggregate(self, uow: Any, recs: Any) -> None: ...

class SaveUpdateState(PostSortRec):
    state: Any = ...
    mapper: Any = ...
    sort_key: Any = ...
    def __init__(self, uow: Any, state: Any) -> None: ...
    def execute_aggregate(self, uow: Any, recs: Any) -> None: ...

class DeleteState(PostSortRec):
    state: Any = ...
    mapper: Any = ...
    sort_key: Any = ...
    def __init__(self, uow: Any, state: Any) -> None: ...
    def execute_aggregate(self, uow: Any, recs: Any) -> None: ...
