File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -2554,6 +2554,18 @@ types.
25542554 import threading
25552555 assert isinstance(threading.Thread(name='Bob'), Named)
25562556
2557+ Runtime checkability of protocols is not inherited. A subclass of a runtime-checkable protocol
2558+ is only runtime-checkable if 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+
25572569 This decorator raises :exc: `TypeError ` when applied to a non-protocol class.
25582570
25592571 .. note ::
You can’t perform that action at this time.
0 commit comments