@@ -190,7 +190,18 @@ use CPython's behavior to determine when to use the ``@disjoint_base`` decorator
190
190
add support for alternative implementations (for example, branching on the value of :py:data: `sys.implementation.name <sys.implementation> `),
191
191
stubs could condition the presence of the ``@disjoint_base `` decorator on the implementation where necessary.
192
192
193
- Similarly, the exact set of classes that are disjoint bases at runtime may change in future versions of Python.
193
+ Although the concept of "disjoint bases" (referred to as "solid bases") in the CPython implementation has existed
194
+ for decades, the rules for deciding which classes are disjoint bases have occasionally changed.
195
+ Before Python 3.12, adding a ``__dict__ `` or support for weakrefs relative to the base class could make a
196
+ class a disjoint base. In practice, this often meant that Python-implemented classes inheriting from
197
+ classes implemented in C, such as :func: `~collections.namedtuple ` classes, were themselves disjoint bases.
198
+ This behavior was changed in Python 3.12 by
199
+ `python/cpython#96028 <https://github.com/python/cpython/pull/96028 >`__.
200
+ This PEP focuses on supporting the behavior of Python 3.12 and later, which is simpler and easier to understand.
201
+ Type checkers may choose to implement a version of the pre-3.12 behavior if they wish, but doing this correctly
202
+ requires information that is not currently available in the type system.
203
+
204
+ The exact set of classes that are disjoint bases at runtime may change again in future versions of Python.
194
205
If this were to happen, the type stubs used by type checkers could be updated to reflect this new reality.
195
206
In other words, this PEP adds the concept of disjoint bases to the type system, but it does not prescribe exactly
196
207
which classes are disjoint bases.
@@ -360,7 +371,10 @@ explain to users why type checkers treat certain branches as unreachable.
360
371
Reference Implementation
361
372
========================
362
373
363
- None yet.
374
+ The runtime implementation of the ``@disjoint_base `` decorator will be available in
375
+ typing-extensions 4.15.0.
376
+ `python/mypy#19678 <https://github.com/python/mypy/pull/19678 >`__
377
+ implements support for disjoint bases in mypy and in the stubtest tool.
364
378
365
379
Appendix
366
380
========
0 commit comments