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

import re
import types
import graphviz
import sympy
from collections.abc import AsyncGenerator, Generator, Iterable, Sequence
from typing import Any, Final, Literal, NamedTuple, Protocol, TYPE_CHECKING, TypeVar, Union, overload
from typing_extensions import TypeAlias, TypeGuard
from plotly.graph_objs import Figure
from pydeck import Deck
from streamlit.delta_generator import DeltaGenerator

"""A bunch of useful utilities for dealing with types."""
if TYPE_CHECKING:
    ...
T = TypeVar("T")
NumpyShape: TypeAlias = tuple[int, ...]
class SupportsStr(Protocol):
    def __str__(self) -> str:
        ...
    


class SupportsReprHtml(Protocol):
    ...


class CustomDict(Protocol):
    """Protocol for Streamlit native custom dictionaries (e.g. session state, secrets, query params).
    that can be converted to a dict.

    All these implementations should provide a to_dict method.
    """
    def to_dict(self) -> dict[str, Any]:
        ...
    


@overload
def is_type(obj: object, fqn_type_pattern: Literal["pydeck.bindings.deck.Deck"]) -> TypeGuard[Deck]:
    ...

@overload
def is_type(obj: object, fqn_type_pattern: Literal["plotly.graph_objs._figure.Figure"]) -> TypeGuard[Figure]:
    ...

@overload
def is_type(obj: object, fqn_type_pattern: str | re.Pattern[str]) -> bool:
    ...

def is_type(obj: object, fqn_type_pattern: str | re.Pattern[str]) -> bool:
    """Check type without importing expensive modules.

    Parameters
    ----------
    obj : object
        The object to type-check.
    fqn_type_pattern : str or regex
        The fully-qualified type string or a regular expression.
        Regexes should start with `^` and end with `$`.

    Example
    -------

    To check whether something is a Matplotlib Figure without importing
    matplotlib, use:

    >>> is_type(foo, "matplotlib.figure.Figure")

    """
    ...

def get_fqn(the_type: type) -> str:
    """Get module.type_name for a given type."""
    ...

def get_fqn_type(obj: object) -> str:
    """Get module.type_name for a given object."""
    ...

_BYTES_LIKE_TYPES: Final[tuple[type, ...]] = ...
BytesLike: TypeAlias = Union[bytes, bytearray]
def is_bytes_like(obj: object) -> TypeGuard[BytesLike]:
    """True if the type is considered bytes-like for the purposes of
    protobuf data marshalling.
    """
    ...

def to_bytes(obj: BytesLike) -> bytes:
    """Converts the given object to bytes.

    Only types for which `is_bytes_like` is true can be converted; anything
    else will result in an exception.
    """
    ...

_SYMPY_RE: Final = ...
def is_sympy_expression(obj: object) -> TypeGuard[sympy.Expr]:
    """True if input is a SymPy expression."""
    ...

_ALTAIR_RE: Final = ...
def is_altair_chart(obj: object) -> bool:
    """True if input looks like an Altair chart."""
    ...

_PILLOW_RE: Final = ...
def is_pillow_image(obj: object) -> bool:
    """True if input looks like a pillow image."""
    ...

def is_keras_model(obj: object) -> bool:
    """True if input looks like a Keras model."""
    ...

_OPENAI_CHUNK_RE: Final = ...
def is_openai_chunk(obj: object) -> bool:
    """True if input looks like an OpenAI chat completion chunk."""
    ...

def is_plotly_chart(obj: object) -> TypeGuard[Figure | list[Any] | dict[str, Any]]:
    """True if input looks like a Plotly chart."""
    ...

def is_graphviz_chart(obj: object) -> TypeGuard[graphviz.Graph | graphviz.Digraph]:
    """True if input looks like a GraphViz chart."""
    ...

def is_delta_generator(obj: object) -> TypeGuard[DeltaGenerator]:
    """True if input looks like a DeltaGenerator."""
    ...

def is_function(x: object) -> TypeGuard[types.FunctionType]:
    """Return True if x is a function."""
    ...

def has_callable_attr(obj: object, name: str) -> bool:
    """True if obj has the specified attribute that is callable."""
    ...

def is_namedtuple(x: object) -> TypeGuard[NamedTuple]:
    """True if obj is an instance of a namedtuple."""
    ...

def is_dataclass_instance(obj: object) -> bool:
    """True if obj is an instance of a dataclass."""
    ...

def is_pydeck(obj: object) -> TypeGuard[Deck]:
    """True if input looks like a pydeck chart."""
    ...

def is_pydantic_model(obj) -> bool:
    """True if input looks like a Pydantic model instance."""
    ...

def is_custom_dict(obj: object) -> TypeGuard[CustomDict]:
    """True if input looks like one of the Streamlit custom dictionaries."""
    ...

def is_iterable(obj: object) -> TypeGuard[Iterable[Any]]:
    ...

def is_list_like(obj: object) -> TypeGuard[Sequence[Any]]:
    """True if input looks like a list."""
    ...

def check_python_comparable(seq: Sequence[Any]) -> None:
    """Check if the sequence elements support "python comparison".
    That means that the equality operator (==) returns a boolean value.
    Which is not True for e.g. numpy arrays and pandas series.
    """
    ...

def is_altair_version_less_than(v: str) -> bool:
    """Return True if the current Altair version is less than the input version.

    Parameters
    ----------
    v : str
        Version string, e.g. "0.25.0"

    Returns
    -------
    bool


    Raises
    ------
    InvalidVersion
        If the version strings are not valid.

    """
    ...

def is_version_less_than(v1: str, v2: str) -> bool:
    """Return True if the v1 version string is less than the v2 version string
    based on semantic versioning.

    Raises
    ------
    InvalidVersion
        If the version strings are not valid.
    """
    ...

def async_generator_to_sync(async_gen: AsyncGenerator[Any, Any]) -> Generator[Any, Any, Any]:
    """Convert an async generator to a synchronous generator."""
    ...

