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

import types
from contextlib import contextmanager
from typing import Any, Callable, Dict, Generic, Iterator, Mapping, MutableMapping, Optional, TypeVar
from typing_extensions import ParamSpec
from ._restrictions import RestrictionContext, SandboxRestrictions

"""Restrictive importer for workflow sandbox.

.. warning::
    This API for this module is considered unstable and may change in future.
"""
logger = ...
LOG_TRACE = ...
_trace_depth = ...
class Importer:
    """Importer that restricts modules."""
    def __init__(self, restrictions: SandboxRestrictions, restriction_context: RestrictionContext) -> None:
        """Create importer."""
        ...
    
    @contextmanager
    def applied(self) -> Iterator[None]:
        """Context manager to apply this restrictive import.

        .. warning::
            This currently alters global sys.modules and builtins.__import__
            while it is running and therefore should be locked against other
            code running at the same time.
        """
        ...
    


_T = TypeVar("_T")
class _ThreadLocalOverride(Generic[_T]):
    def __init__(self, orig: _T) -> None:
        ...
    
    @property
    def maybe_current(self) -> Optional[_T]:
        ...
    
    @property
    def current(self) -> _T:
        ...
    
    @current.setter
    def current(self, v: _T) -> None:
        ...
    
    @current.deleter
    def current(self) -> None:
        ...
    
    @contextmanager
    def applied(self, obj: Any, attr: str, current: _T) -> Iterator[None]:
        ...
    
    @contextmanager
    def unapplied(self) -> Iterator[None]:
        ...
    


class _ThreadLocalSysModules(_ThreadLocalOverride[Dict[str, types.ModuleType]], MutableMapping[str, types.ModuleType]):
    def __contains__(self, key: object) -> bool:
        ...
    
    def __delitem__(self, key: str) -> None:
        ...
    
    def __getitem__(self, key: str) -> types.ModuleType:
        ...
    
    def __len__(self) -> int:
        ...
    
    def __iter__(self) -> Iterator[str]:
        ...
    
    def __setitem__(self, key: str, value: types.ModuleType) -> None:
        ...
    
    def __or__(self, other: Mapping[str, types.ModuleType]) -> Dict[str, types.ModuleType]:
        ...
    
    def __ior__(self, other: Mapping[str, types.ModuleType]) -> Dict[str, types.ModuleType]:
        ...
    
    __ror__ = ...
    def copy(self) -> Dict[str, types.ModuleType]:
        ...
    
    @classmethod
    def fromkeys(cls, *args, **kwargs) -> Any:
        ...
    


_thread_local_sys_modules = ...
_P = ParamSpec("_P")
class _ThreadLocalCallable(_ThreadLocalOverride[Callable[_P, _T]]):
    def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _T:
        ...
    


_thread_local_import = ...
_thread_local_builtins: Dict[str, _ThreadLocalCallable] = ...
