@@ -2527,6 +2527,12 @@ types.
25272527
25282528 .. versionadded :: 3.8
25292529
2530+ .. deprecated-removed :: 3.15 3.20
2531+ It is deprecated to call :func: `isinstance ` and :func: `issubclass ` checks on
2532+ protocol classes that were not explicitly decorated with :func: `!runtime_checkable `
2533+ but that inherit from a runtime-checkable protocol class. This will throw
2534+ a :exc: `TypeError ` in Python 3.20.
2535+
25302536.. decorator :: runtime_checkable
25312537
25322538 Mark a protocol class as a runtime protocol.
@@ -2548,6 +2554,18 @@ types.
25482554 import threading
25492555 assert isinstance(threading.Thread(name='Bob'), Named)
25502556
2557+ Runtime checkability of protocols is not inherited. A subclass of a runtime-checkable protocol
2558+ is only runtime-checkable if it is explicitly marked as such, regardless of class hierarchy::
2559+
2560+ @runtime_checkable
2561+ class Iterable(Protocol):
2562+ def __iter__(self): ...
2563+
2564+ # Without @runtime_checkable, Reversible would no longer be runtime-checkable.
2565+ @runtime_checkable
2566+ class Reversible(Iterable, Protocol):
2567+ def __reversed__(self): ...
2568+
25512569 This decorator raises :exc: `TypeError ` when applied to a non-protocol class.
25522570
25532571 .. note ::
@@ -2588,6 +2606,11 @@ types.
25882606 protocol. See :ref: `What's new in Python 3.12 <whatsnew-typing-py312 >`
25892607 for more details.
25902608
2609+ .. deprecated-removed :: 3.15 3.20
2610+ It is deprecated to call :func: `isinstance ` and :func: `issubclass ` checks on
2611+ protocol classes that were not explicitly decorated with :func: `!runtime_checkable `
2612+ but that inherit from a runtime-checkable protocol class. This will throw
2613+ a :exc: `TypeError ` in Python 3.20.
25912614
25922615.. class :: TypedDict(dict)
25932616
0 commit comments