From c788e9ba6310f11c1c0803d703159de02fd67386 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Fri, 13 Nov 2026 15:12:26 -0800 Subject: [PATCH 1/2] Accept frozendict namespaces in type constructors on Python 3.15 --- stdlib/builtins.pyi | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 9fdbf0e4aa8d..f522167b7b95 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -202,13 +202,13 @@ class type: @overload def __init__(self, o: object, /) -> None: ... @overload - def __init__(self, name: str, bases: tuple[type, ...], dict: dict[str, Any], /, **kwds: Any) -> None: ... + def __init__(self, name: str, bases: tuple[type, ...], dict: _TypeNamespace, /, **kwds: Any) -> None: ... @overload def __new__(cls, o: object, /) -> type: ... @overload def __new__( - cls: type[_typeshed.Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], /, **kwds: Any + cls: type[_typeshed.Self], name: str, bases: tuple[type, ...], namespace: _TypeNamespace, /, **kwds: Any ) -> _typeshed.Self: ... def __call__(self, *args: Any, **kwds: Any) -> Any: ... @@ -1429,6 +1429,11 @@ if sys.version_info >= (3, 15): @overload def __ror__(self, value: frozendict[_T1, _T2], /) -> frozendict[_KT | _T1, _VT_co | _T2]: ... + _TypeNamespace: TypeAlias = dict[str, Any] | frozendict[str, Any] + +else: + _TypeNamespace: TypeAlias = dict[str, Any] + @disjoint_base class set(MutableSet[_T]): @overload From 18f74a2756eaa0e5e887f821ebd1f053013e83f1 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Sat, 14 Nov 2026 18:53:06 -0800 Subject: [PATCH 2/2] Move the type namespace alias before its first use --- stdlib/builtins.pyi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index f522167b7b95..5ccbd902cbbe 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -99,6 +99,11 @@ _StopT_co = TypeVar("_StopT_co", covariant=True, default=_StartT_co) # slice[A] # FIXME: https://github.com/python/typing/issues/213 (replace step=start|stop with step=start&stop) _StepT_co = TypeVar("_StepT_co", covariant=True, default=_StartT_co | _StopT_co) # slice[A,B] -> slice[A, B, A|B] +if sys.version_info >= (3, 15): + _TypeNamespace: TypeAlias = dict[str, Any] | frozendict[str, Any] +else: + _TypeNamespace: TypeAlias = dict[str, Any] + @disjoint_base class object: __doc__: str | None @@ -1429,11 +1434,6 @@ if sys.version_info >= (3, 15): @overload def __ror__(self, value: frozendict[_T1, _T2], /) -> frozendict[_KT | _T1, _VT_co | _T2]: ... - _TypeNamespace: TypeAlias = dict[str, Any] | frozendict[str, Any] - -else: - _TypeNamespace: TypeAlias = dict[str, Any] - @disjoint_base class set(MutableSet[_T]): @overload