2 from typing import Any, Callable, Generic, TypeVar, overload
3 from typing_extensions import final
5 if sys.version_info >= (3, 9):
6 from types import GenericAlias
8 _C = TypeVar("_C", bound=Callable[..., Any])
12 class CallableProxyType(Generic[_C]): # "weakcallableproxy"
13 def __getattr__(self, attr: str) -> Any: ...
16 class ProxyType(Generic[_T]): # "weakproxy"
17 def __getattr__(self, attr: str) -> Any: ...
19 class ReferenceType(Generic[_T]):
20 __callback__: Callable[[ReferenceType[_T]], Any]
21 def __init__(self, o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> None: ...
22 def __call__(self) -> _T | None: ...
23 def __hash__(self) -> int: ...
24 if sys.version_info >= (3, 9):
25 def __class_getitem__(cls, item: Any) -> GenericAlias: ...
29 def getweakrefcount(__object: Any) -> int: ...
30 def getweakrefs(object: Any) -> list[Any]: ...
32 def proxy(object: _C, callback: Callable[[_C], Any] | None = ...) -> CallableProxyType[_C]: ...
34 # Return CallableProxyType if object is callable, ProxyType otherwise
36 def proxy(object: _T, callback: Callable[[_T], Any] | None = ...) -> Any: ...