We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0adbbff commit 985e267Copy full SHA for 985e267
1 file changed
Doc/library/typing.rst
@@ -2554,6 +2554,18 @@ types.
2554
import threading
2555
assert isinstance(threading.Thread(name='Bob'), Named)
2556
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
2566
+ class Reversible(Iterable, Protocol):
2567
+ def __reversed__(self): ...
2568
2569
This decorator raises :exc:`TypeError` when applied to a non-protocol class.
2570
2571
.. note::
0 commit comments