from __future__ import annotations

import logging
from collections.abc import Callable, Iterable, Iterator, Mapping
from typing import Any, Hashable, Literal

__all__: tuple[str, ...]

def __getattr__(name: str) -> Any: ...

class WarnOnce:
    def __init__(
        self, logger: logging.Logger, msg: str, *, maxsize: int = ...
    ) -> None: ...
    def __call__(
        self,
        data: Mapping[Hashable, Any] | Hashable,
        value: Any | None = ...,
    ) -> None: ...
    def clear(self) -> None: ...

class LazyImportProxy:
    def __init__(
        self,
        module_name: str,
        attr: str | None,
        emit: Literal["warn", "log", "both"],
        fallback: Any | None,
    ) -> None: ...
    def __getattr__(self, name: str) -> Any: ...
    def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
    def __bool__(self) -> bool: ...
    def __iter__(self) -> Iterator[Any]: ...
    def resolve(self) -> Any: ...

class ImportRegistry:
    limit: int
    failed: Mapping[str, None]
    warned: set[str]
    lock: Any

    def record_failure(self, key: str, *, module: str | None = ...) -> None: ...
    def discard(self, key: str) -> None: ...
    def mark_warning(self, module: str) -> bool: ...
    def clear(self) -> None: ...
    def __contains__(self, key: str) -> bool: ...

EMIT_MAP: Mapping[str, Callable[[str], None]]
IMPORT_LOG: ImportRegistry
_IMPORT_STATE: ImportRegistry
_LOGGING_CONFIGURED: bool
_DEFAULT_CACHE_SIZE: int
_FAILED_IMPORT_LIMIT: int

def _configure_root() -> None: ...
def _reset_import_state() -> None: ...
def _reset_logging_state() -> None: ...
def _warn_failure(module: str, attr: str | None, err: Exception) -> None: ...
def cached_import(
    module_name: str,
    attr: str | None = ...,
    *,
    fallback: Any | None = ...,
    emit: Literal["warn", "log", "both"] = ...,
    lazy: bool = ...,
) -> Any | None: ...
def warm_cached_import(
    module: str | tuple[str, str | None] | Iterable[str | tuple[str, str | None]],
    *extra: str | tuple[str, str | None],
    attr: str | None = ...,
    fallback: Any | None = ...,
    emit: Literal["warn", "log", "both"] = ...,
    lazy: bool = ...,
    resolve: bool = ...,
) -> Any | dict[str, Any | None]: ...
def get_logger(name: str) -> logging.Logger: ...
def get_numpy() -> Any | None: ...
def get_nodenx() -> Any | None: ...
def prune_failed_imports(*modules: str) -> None: ...
def warn_once(logger: logging.Logger, msg: str, *, maxsize: int = ...) -> WarnOnce: ...
