Skip to content

Commit

Permalink
[3.10] bpo-38908: [docs] Add changes to 3.10 whatsnew and fix some mi…
Browse files Browse the repository at this point in the history
…nor inaccuracies in news (GH-26096) (GH-26337)

The fix only applies to ``isinstance``. ``issubclass`` isn't affected (because it was always working to begin with). So I also fixed the news to reflect that.
(cherry picked from commit 8450e8a)


Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
  • Loading branch information
miss-islington and Fidget-Spinner committed May 27, 2021
1 parent 4431922 commit 09696a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,14 @@ Add new function :func:`typing.is_typeddict` to introspect if an annotation
is a :class:`typing.TypedDict`.
(Contributed by Patrick Reader in :issue:`41792`)
Subclasses of ``typing.Protocol`` which only have data variables declared
will now raise a ``TypeError`` when checked with ``isinstance`` unless they
are decorated with :func:`runtime_checkable`. Previously, these checks
passed silently. Users should decorate their
subclasses with the :func:`runtime_checkable` decorator
if they want runtime protocols.
(Contributed by Yurii Karabas in :issue:`38908`)
unittest
--------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Fix issue where :mod:`typing` protocols without the ``@runtime_checkable``
decorator did not raise a ``TypeError`` when used with ``issubclass`` and
``isinstance``. Now, subclassses of ``typing.Protocol`` will raise a
``TypeError`` when used with with those checks.
Subclasses of ``typing.Protocol`` which only have data variables declared
will now raise a ``TypeError`` when checked with ``isinstance`` unless they
are decorated with :func:`runtime_checkable`. Previously, these checks
passed silently.
Patch provided by Yurii Karabas.

0 comments on commit 09696a3

Please sign in to comment.