"""
This type stub file was generated by pyright.
"""

from collections.abc import Callable
from typing import TYPE_CHECKING
from graph_sitter.codebase.diff_lite import DiffLite
from graph_sitter.codebase.transactions import Transaction, TransactionPriority
from graph_sitter.core.file import File

if TYPE_CHECKING:
    ...
logger = ...
class TransactionError(Exception):
    ...


class TransactionManager:
    """Responsible for handling `Transaction` objects - basically an atomic modification of a codebase.

    This is used by the Codebase class to queue up transactions and then commit them in bulk.
    """
    queued_transactions: dict[str, list[Transaction]]
    pending_undos: set[Callable[[], None]]
    _commiting: bool = ...
    max_transactions: int | None = ...
    stopwatch_start = ...
    stopwatch_max_seconds: int | None = ...
    def __init__(self) -> None:
        ...
    
    def sort_transactions(self) -> None:
        ...
    
    def clear_transactions(self) -> None:
        """Should be called between tests to remove any potential extraneous transactions. Makes sure we reset max_transactions as well."""
        ...
    
    def get_transactions_str(self) -> str:
        """Returns a human-readable string representation of the transactions"""
        ...
    
    def get_num_transactions(self) -> int:
        """Returns total number of transactions created to date"""
        ...
    
    def set_max_transactions(self, max_transactions: int | None = ...) -> None:
        ...
    
    def max_transactions_exceeded(self) -> bool:
        """Util method to check if the max transactions limit has been exceeded."""
        ...
    
    def reset_stopwatch(self, max_seconds: int | None = ...) -> int:
        ...
    
    def is_time_exceeded(self) -> bool:
        ...
    
    def add_file_add_transaction(self, filepath: str) -> None:
        ...
    
    def add_file_rename_transaction(self, file: File, filepath: str, new_filepath: str) -> None:
        ...
    
    def add_file_remove_transaction(self, filepath: str, file: File) -> None:
        ...
    
    def add_transaction(self, transaction: Transaction, dedupe: bool = ..., solve_conflicts: bool = ...) -> bool:
        ...
    
    def check_limits(self): # -> None:
        ...
    
    def check_max_transactions(self): # -> None:
        ...
    
    def check_max_preview_time(self): # -> None:
        ...
    
    def to_commit(self, files: set[str] | None = ...) -> set[str]:
        """Get node ids of files to commit"""
        ...
    
    def commit(self, files: set[str]) -> set[DiffLite]:
        """Execute transactions in bulk for each file, in reverse order of start_byte.
        Returns the set of diffs that were committed.
        """
        ...
    
    def get_transactions_at_range(self, file_path: str, start_byte: int, end_byte: int, transaction_order: TransactionPriority | None = ..., *, combined: bool = ...) -> list[Transaction]:
        """Returns list of queued transactions that matches the given filtering criteria.

        Args:
            combined: Return a list of transactions which collectively apply to the given range
        """
        ...
    


