From 59bb6ff07176e5ac863575b3da9759146104c738 Mon Sep 17 00:00:00 2001 From: Huanyi Xie <74809554+xiehuanyi@users.noreply.github.com> Date: Tue, 13 Oct 2026 21:07:02 +0300 Subject: [PATCH] Make weak reference callbacks optional and read-only --- stdlib/weakref.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index e81052de7d26..1364a6177d1d 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -54,7 +54,8 @@ class ProxyType(Generic[_T]): # "weakproxy" @disjoint_base class ReferenceType(Generic[_T]): # "weakref" - __callback__: Callable[[Self], Any] + @property + def __callback__(self) -> Callable[[Self], Any] | None: ... def __new__(cls, o: _T, callback: Callable[[Self], Any] | None = ..., /) -> Self: ... def __call__(self) -> _T | None: ... def __eq__(self, value: object, /) -> bool: ...