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

import threading
from contextlib import contextmanager
from typing import Any, Callable, TYPE_CHECKING
from collections.abc import Iterator
from streamlit.proto.WidgetStates_pb2 import WidgetState as WidgetStateProto, WidgetStates as WidgetStatesProto
from streamlit.runtime.state.common import RegisterWidgetResult, T, WidgetMetadata
from streamlit.runtime.state.query_params import QueryParams
from streamlit.runtime.state.session_state import SessionState

if TYPE_CHECKING:
    ...
class SafeSessionState:
    """Thread-safe wrapper around SessionState.

    When AppSession gets a re-run request, it can interrupt its existing
    ScriptRunner and spin up a new ScriptRunner to handle the request.
    When this happens, the existing ScriptRunner will continue executing
    its script until it reaches a yield point - but during this time, it
    must not mutate its SessionState.
    """
    _state: SessionState
    _lock: threading.RLock
    _yield_callback: Callable[[], None]
    def __init__(self, state: SessionState, yield_callback: Callable[[], None]) -> None:
        ...
    
    def register_widget(self, metadata: WidgetMetadata[T], user_key: str | None) -> RegisterWidgetResult[T]:
        ...
    
    def on_script_will_rerun(self, latest_widget_states: WidgetStatesProto) -> None:
        ...
    
    def on_script_finished(self, widget_ids_this_run: set[str]) -> None:
        ...
    
    def maybe_check_serializable(self) -> None:
        ...
    
    def get_widget_states(self) -> list[WidgetStateProto]:
        """Return a list of serialized widget values for each widget with a value."""
        ...
    
    def is_new_state_value(self, user_key: str) -> bool:
        ...
    
    @property
    def filtered_state(self) -> dict[str, Any]:
        """The combined session and widget state, excluding keyless widgets."""
        ...
    
    def __getitem__(self, key: str) -> Any:
        ...
    
    def __setitem__(self, key: str, value: Any) -> None:
        ...
    
    def __delitem__(self, key: str) -> None:
        ...
    
    def __contains__(self, key: str) -> bool:
        ...
    
    def __getattr__(self, key: str) -> Any:
        ...
    
    def __setattr__(self, key: str, value: Any) -> None:
        ...
    
    def __delattr__(self, key: str) -> None:
        ...
    
    def __repr__(self): # -> str:
        """Presents itself as a simple dict of the underlying SessionState instance."""
        ...
    
    @contextmanager
    def query_params(self) -> Iterator[QueryParams]:
        ...
    


