from multiprocessing.context import BaseContext
from types import TracebackType
from typing import Any

from typing_extensions import Self

__all__ = ["BaseManager", "BaseProxy", "SyncManager", "Token"]

class Token:
    typeid: str | None
    address: tuple[str, int] | str | None
    id: str | None
    def __init__(
        self,
        typeid: str | None,
        address: tuple[str, int] | str | None,
        id: str | None,
    ) -> None: ...

class BaseProxy:
    def __init__(
        self,
        token: Any,
        serializer: str,
        manager: Any = ...,
        authkey: str | bytes | None = ...,
        exposed: Any = ...,
        incref: bool = ...,
    ) -> None: ...
    def __deepcopy__(self, memo: dict[int, Any]) -> BaseProxy: ...

class BaseManager:
    def __init__(
        self,
        address: str | tuple[str, int] | None = ...,
        authkey: bytes | None = ...,
        serializer: str = ...,
        ctx: BaseContext | None = ...,
    ) -> None: ...
    def start(
        self, initializer: Any = ..., initargs: tuple[Any, ...] = ...
    ) -> None: ...
    def get_server(self) -> Any: ...
    def connect(self) -> None: ...
    def join(self, timeout: float | None = ...) -> None: ...
    @classmethod
    def register(
        cls,
        typeid: str,
        callable: Any = ...,
        proxytype: type[Any] | None = ...,
        exposed: Any = ...,
        method_to_typeid: dict[str, str] | None = ...,
        create_method: bool = ...,
    ) -> None: ...
    @property
    def address(self) -> tuple[str, int] | str | None: ...
    def __enter__(self) -> Self: ...
    def __exit__(
        self,
        exc_type: type[BaseException] | None,
        exc_val: BaseException | None,
        exc_tb: TracebackType | None,
    ) -> None: ...

class SyncManager(BaseManager):
    def Barrier(self, *args: Any, **kwds: Any) -> Any: ...
    def BoundedSemaphore(self, *args: Any, **kwds: Any) -> Any: ...
    def Condition(self, *args: Any, **kwds: Any) -> Any: ...
    def Event(self, *args: Any, **kwds: Any) -> Any: ...
    def JoinableQueue(self, *args: Any, **kwds: Any) -> Any: ...
    def Lock(self, *args: Any, **kwds: Any) -> Any: ...
    def Namespace(self, *args: Any, **kwds: Any) -> Any: ...
    def Pool(self, *args: Any, **kwds: Any) -> Any: ...
    def Queue(self, *args: Any, **kwds: Any) -> Any: ...
    def RLock(self, *args: Any, **kwds: Any) -> Any: ...
    def Semaphore(self, *args: Any, **kwds: Any) -> Any: ...
    def Value(self, *args: Any, **kwds: Any) -> Any: ...
    def Array(self, *args: Any, **kwds: Any) -> Any: ...
    def dict(self, *args: Any, **kwds: Any) -> Any: ...
    def list(self, *args: Any, **kwds: Any) -> Any: ...
