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

from typing import Any, Callable, TYPE_CHECKING
from streamlit.runtime.scriptrunner_utils.script_requests import RerunData
from streamlit.runtime.scriptrunner_utils.script_run_context import ScriptRunContext

if TYPE_CHECKING:
    ...
class modified_sys_path:
    """A context for prepending a directory to sys.path for a second.

    Code inspired by IPython:
    Source: https://github.com/ipython/ipython/blob/master/IPython/utils/syspathcontext.py#L42
    """
    def __init__(self, main_script_path: str) -> None:
        ...
    
    def __repr__(self) -> str:
        ...
    
    def __enter__(self): # -> None:
        ...
    
    def __exit__(self, type, value, traceback): # -> Literal[False]:
        ...
    


def exec_func_with_error_handling(func: Callable[[], Any], ctx: ScriptRunContext) -> tuple[Any | None, bool, RerunData | None, bool, Exception | None,]:
    """Execute the passed function wrapped in a try/except block.

    This function is called by the script runner to execute the user's script or
    fragment reruns, but also for the execution of fragment code in context of a normal
    app run. This wrapper ensures that handle_uncaught_exception messages show up in the
    correct context.

    Parameters
    ----------
    func : callable
        The function to execute wrapped in the try/except block.
    ctx : ScriptRunContext
        The context in which the script is being run.

    Returns
    -------
    tuple
        A tuple containing:
        - The result of the passed function.
        - A boolean indicating whether the script ran without errors (RerunException and
            StopException don't count as errors).
        - The RerunData instance belonging to a RerunException if the script was
            interrupted by a RerunException.
        - A boolean indicating whether the script was stopped prematurely (False for
            RerunExceptions, True for all other exceptions).
        - The uncaught exception if one occurred, None otherwise
    """
    ...

