1 from _weakrefset import WeakSet as WeakSet
2 from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, MutableMapping, Tuple, Type, TypeVar, overload
5 CallableProxyType as CallableProxyType,
6 ProxyType as ProxyType,
7 ReferenceType as ReferenceType,
8 getweakrefcount as getweakrefcount,
9 getweakrefs as getweakrefs,
18 _CallableT = TypeVar("_CallableT", bound=Callable[..., Any])
20 ProxyTypes: Tuple[Type[Any], ...]
22 class WeakMethod(ref[_CallableT], Generic[_CallableT]):
23 def __new__(cls, meth: _CallableT, callback: Callable[[_CallableT], object] | None = ...) -> WeakMethod[_CallableT]: ...
24 def __call__(self) -> _CallableT | None: ...
26 class WeakValueDictionary(MutableMapping[_KT, _VT]):
28 def __init__(self) -> None: ...
30 def __init__(self, __other: Mapping[_KT, _VT] | Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
31 def __len__(self) -> int: ...
32 def __getitem__(self, k: _KT) -> _VT: ...
33 def __setitem__(self, k: _KT, v: _VT) -> None: ...
34 def __delitem__(self, v: _KT) -> None: ...
35 def __contains__(self, o: object) -> bool: ...
36 def __iter__(self) -> Iterator[_KT]: ...
37 def __str__(self) -> str: ...
38 def copy(self) -> WeakValueDictionary[_KT, _VT]: ...
39 # These are incompatible with Mapping
40 def keys(self) -> Iterator[_KT]: ... # type: ignore
41 def values(self) -> Iterator[_VT]: ... # type: ignore
42 def items(self) -> Iterator[tuple[_KT, _VT]]: ... # type: ignore
43 def itervaluerefs(self) -> Iterator[KeyedRef[_KT, _VT]]: ...
44 def valuerefs(self) -> list[KeyedRef[_KT, _VT]]: ...
45 def setdefault(self, key: _KT, default: _VT = ...) -> _VT: ...
47 def pop(self, key: _KT) -> _VT: ...
49 def pop(self, key: _KT, default: _VT | _T = ...) -> _VT | _T: ...
51 class KeyedRef(ref[_T], Generic[_KT, _T]):
53 # This __new__ method uses a non-standard name for the "cls" parameter
54 def __new__(type, ob: _T, callback: Callable[[_T], Any], key: _KT) -> KeyedRef[_KT, _T]: ... # type: ignore
55 def __init__(self, ob: _T, callback: Callable[[_T], Any], key: _KT) -> None: ...
57 class WeakKeyDictionary(MutableMapping[_KT, _VT]):
59 def __init__(self, dict: None = ...) -> None: ...
61 def __init__(self, dict: Mapping[_KT, _VT] | Iterable[tuple[_KT, _VT]]) -> None: ...
62 def __len__(self) -> int: ...
63 def __getitem__(self, k: _KT) -> _VT: ...
64 def __setitem__(self, k: _KT, v: _VT) -> None: ...
65 def __delitem__(self, v: _KT) -> None: ...
66 def __contains__(self, o: object) -> bool: ...
67 def __iter__(self) -> Iterator[_KT]: ...
68 def __str__(self) -> str: ...
69 def copy(self) -> WeakKeyDictionary[_KT, _VT]: ...
70 # These are incompatible with Mapping
71 def keys(self) -> Iterator[_KT]: ... # type: ignore
72 def values(self) -> Iterator[_VT]: ... # type: ignore
73 def items(self) -> Iterator[tuple[_KT, _VT]]: ... # type: ignore
74 def keyrefs(self) -> list[ref[_KT]]: ...
75 def setdefault(self, key: _KT, default: _VT = ...) -> _VT: ...
77 def pop(self, key: _KT) -> _VT: ...
79 def pop(self, key: _KT, default: _VT | _T = ...) -> _VT | _T: ...
82 def __init__(self, __obj: object, __func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
83 def __call__(self, _: Any = ...) -> Any | None: ...
84 def detach(self) -> tuple[Any, Any, Tuple[Any, ...], dict[str, Any]] | None: ...
85 def peek(self) -> tuple[Any, Any, Tuple[Any, ...], dict[str, Any]] | None: ...