diff --git a/peps/pep-0800.rst b/peps/pep-0800.rst index 887f7b81d1f..5c13bbbdd2e 100644 --- a/peps/pep-0800.rst +++ b/peps/pep-0800.rst @@ -190,7 +190,18 @@ use CPython's behavior to determine when to use the ``@disjoint_base`` decorator add support for alternative implementations (for example, branching on the value of :py:data:`sys.implementation.name `), stubs could condition the presence of the ``@disjoint_base`` decorator on the implementation where necessary. -Similarly, the exact set of classes that are disjoint bases at runtime may change in future versions of Python. +Although the concept of "disjoint bases" (referred to as "solid bases") in the CPython implementation has existed +for decades, the rules for deciding which classes are disjoint bases have occasionally changed. +Before Python 3.12, adding a ``__dict__`` or support for weakrefs relative to the base class could make a +class a disjoint base. In practice, this often meant that Python-implemented classes inheriting from +classes implemented in C, such as :func:`~collections.namedtuple` classes, were themselves disjoint bases. +This behavior was changed in Python 3.12 by +`python/cpython#96028 `__. +This PEP focuses on supporting the behavior of Python 3.12 and later, which is simpler and easier to understand. +Type checkers may choose to implement a version of the pre-3.12 behavior if they wish, but doing this correctly +requires information that is not currently available in the type system. + +The exact set of classes that are disjoint bases at runtime may change again in future versions of Python. If this were to happen, the type stubs used by type checkers could be updated to reflect this new reality. In other words, this PEP adds the concept of disjoint bases to the type system, but it does not prescribe exactly which classes are disjoint bases. @@ -360,7 +371,10 @@ explain to users why type checkers treat certain branches as unreachable. Reference Implementation ======================== -None yet. +The runtime implementation of the ``@disjoint_base`` decorator will be available in +typing-extensions 4.15.0. +`python/mypy#19678 `__ +implements support for disjoint bases in mypy and in the stubtest tool. Appendix ========