[Python-checkins] bpo-43453: Update and re-add example to typing runtime_checkable (GH-27013)

miss-islington webhook-mailer at python.org
Mon Jul 5 16:46:06 EDT 2021


https://github.com/python/cpython/commit/846cc4d28025ac4319069ec3c6db9526c75efd40
commit: 846cc4d28025ac4319069ec3c6db9526c75efd40
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-07-05T13:46:02-07:00
summary:

bpo-43453: Update and re-add example to typing runtime_checkable (GH-27013)


Co-authored-by: Ken Jin <28750310+Fidget-Spinner at users.noreply.github.com>
(cherry picked from commit 17f94e28882e1e2b331ace93f42e8615383dee59)

Co-authored-by: andrei kulakov <andrei.avk at gmail.com>

files:
M Doc/library/typing.rst

diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index e9980a7745d69..b1d67e46fbb5d 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -1232,8 +1232,13 @@ These are not used in annotations. They are building blocks for creating generic
 
    .. note::
 
-        :func:`runtime_checkable` will check only the presence of the required methods,
-        not their type signatures.
+        :func:`runtime_checkable` will check only the presence of the required
+        methods, not their type signatures. For example, :class:`ssl.SSLObject`
+        is a class, therefore it passes an :func:`issubclass`
+        check against :data:`Callable`.  However, the
+        :meth:`ssl.SSLObject.__init__` method exists only to raise a
+        :exc:`TypeError` with a more informative message, therefore making
+        it impossible to call (instantiate) :class:`ssl.SSLObject`.
 
    .. versionadded:: 3.8
 



More information about the Python-checkins mailing list