Skip to content

Commit 597ebc8

Browse files
[3.9] bpo-42675: Document collections.abc.Callable changes (GH-23839) (#23852)
1 parent 6ad5fd1 commit 597ebc8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

‎Doc/library/types.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ Standard names are defined for the following types:
260260

261261
.. versionadded:: 3.9
262262

263+
.. versionchanged:: 3.9.2
264+
This type can now be subclassed.
265+
263266

264267
.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)
265268

‎Doc/whatsnew/3.9.rst‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,3 +1497,22 @@ functions and options conditionally available based on the operating system
14971497
version in use at runtime ("weaklinking").
14981498

14991499
(Contributed by Ronald Oussoren and Lawrence D'Anna in :issue:`41100`.)
1500+
1501+
Notable changes in Python 3.9.2
1502+
===============================
1503+
1504+
collections.abc
1505+
---------------
1506+
1507+
:class:`collections.abc.Callable` generic now flattens type parameters, similar
1508+
to what :data:`typing.Callable` currently does. This means that
1509+
``collections.abc.Callable[[int, str], str]`` will have ``__args__`` of
1510+
``(int, str, str)``; previously this was ``([int, str], str)``. To allow this
1511+
change, :class:`types.GenericAlias` can now be subclassed, and a subclass will
1512+
be returned when subscripting the :class:`collections.abc.Callable` type.
1513+
Code which accesses the arguments via :func:`typing.get_args` or ``__args__``
1514+
need to account for this change. A :exc:`DeprecationWarning` may be emitted for
1515+
invalid forms of parameterizing :class:`collections.abc.Callable` which may have
1516+
passed silently in Python 3.9.1. This :exc:`DeprecationWarning` will
1517+
become a :exc:`TypeError` in Python 3.10.
1518+
(Contributed by Ken Jin in :issue:`42195`.)

0 commit comments

Comments
 (0)