stdlib: add __slots__ (#14611)

This commit is contained in:
Jelle Zijlstra
2025-08-21 07:24:59 -07:00
committed by GitHub
parent 28abff1eb3
commit f32d9f08bd
38 changed files with 247 additions and 12 deletions
+3
View File
@@ -65,6 +65,7 @@ ref = ReferenceType
# everything below here is implemented in weakref.py
class WeakMethod(ref[_CallableT]):
__slots__ = ("_func_ref", "_meth_type", "_alive", "__weakref__")
def __new__(cls, meth: _CallableT, callback: Callable[[Self], Any] | None = None) -> Self: ...
def __call__(self) -> _CallableT | None: ...
def __eq__(self, other: object) -> bool: ...
@@ -130,6 +131,7 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]):
def __ior__(self, other: Iterable[tuple[_KT, _VT]]) -> Self: ...
class KeyedRef(ref[_T], Generic[_KT, _T]):
__slots__ = ("key",)
key: _KT
def __new__(type, ob: _T, callback: Callable[[Self], Any], key: _KT) -> Self: ...
def __init__(self, ob: _T, callback: Callable[[Self], Any], key: _KT) -> None: ...
@@ -185,6 +187,7 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]):
def __ior__(self, other: Iterable[tuple[_KT, _VT]]) -> Self: ...
class finalize(Generic[_P, _T]):
__slots__ = ()
def __init__(self, obj: _T, func: Callable[_P, Any], /, *args: _P.args, **kwargs: _P.kwargs) -> None: ...
def __call__(self, _: Any = None) -> Any | None: ...
def detach(self) -> tuple[_T, Callable[_P, Any], tuple[Any, ...], dict[str, Any]] | None: ...