diff options
author | kj <28750310+Fidget-Spinner@users.noreply.github.com> | 2020-12-18 17:39:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-18 17:39:26 (GMT) |
commit | d75f6f78e6ca230d0dacc116dca9d8bf91509b68 (patch) | |
tree | b6f7fd4c8c9b22ba8f2c15b3f32d18201c2e50c5 | |
parent | 17ef4319a34f5a2f95e7823dfb5f5b8cff11882d (diff) | |
download | cpython-d75f6f78e6ca230d0dacc116dca9d8bf91509b68.zip cpython-d75f6f78e6ca230d0dacc116dca9d8bf91509b68.tar.gz cpython-d75f6f78e6ca230d0dacc116dca9d8bf91509b68.tar.bz2 |
bpo-42675: Document collections.abc.Callable changes (GH-23839)
-rw-r--r-- | Doc/library/types.rst | 4 | ||||
-rw-r--r-- | Doc/whatsnew/3.10.rst | 24 |
2 files changed, 28 insertions, 0 deletions
diff --git a/Doc/library/types.rst b/Doc/library/types.rst index 6f0dc25..8e05f84 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -280,6 +280,10 @@ Standard names are defined for the following types: .. versionadded:: 3.9 + .. versionchanged:: 3.9.2 + This type can now be subclassed. + + .. data:: Union The type of :ref:`union type expressions<types-union>`. diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index b690f8d..a6f9b0b 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -179,6 +179,21 @@ codecs Add a :func:`codecs.unregister` function to unregister a codec search function. (Contributed by Hai Shi in :issue:`41842`.) +collections.abc +--------------- + +The ``__args__`` of the :ref:`parameterized generic <types-genericalias>` for +:class:`collections.abc.Callable` are now consistent with :data:`typing.Callable`. +:class:`collections.abc.Callable` generic now flattens type parameters, similar +to what :data:`typing.Callable` currently does. This means that +``collections.abc.Callable[[int, str], str]`` will have ``__args__`` of +``(int, str, str)``; previously this was ``([int, str], str)``. To allow this +change, :class:`types.GenericAlias` can now be subclassed, and a subclass will +be returned when subscripting the :class:`collections.abc.Callable` type. Note +that a :exc:`TypeError` may be raised for invalid forms of parameterizing +:class:`collections.abc.Callable` which may have passed silently in Python 3.9. +(Contributed by Ken Jin in :issue:`42195`.) + contextlib ---------- @@ -507,6 +522,15 @@ Changes in the Python API ignored. (Contributed by Victor Stinner in :issue:`42639`.) +* :class:`collections.abc.Callable` generic now flattens type parameters, similar + to what :data:`typing.Callable` currently does. This means that + ``collections.abc.Callable[[int, str], str]`` will have ``__args__`` of + ``(int, str, str)``; previously this was ``([int, str], str)``. Code which + accesses the arguments via :func:`typing.get_args` or ``__args__`` need to account + for this change. Furthermore, :exc:`TypeError` may be raised for invalid forms + of parameterizing :class:`collections.abc.Callable` which may have passed + silently in Python 3.9. + (Contributed by Ken Jin in :issue:`42195`.) CPython bytecode changes ======================== |