Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Doc/library/functools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,17 @@ The :mod:`functools` module defines the following functions:
... for i, elem in enumerate(arg):
... print(i, elem)

.. note::
The :mod:`typing` module provides a number of aliases to
builtin classes, as well as classes found elsewhere in the standard
library. All have been deprecated since Python 3.9 (see :pep:`585`).
Comment thread
AlexWaygood marked this conversation as resolved.
Annotating the first argument of a ``@singledispatch`` implementation
with one of these aliases is not supported, and will lead to a
:exc:`TypeError` being raised in Python 3.7 and above. Use
:pep:`585`-style syntax instead: ``list`` rather than ``typing.List``,
``collections.abc.Iterable[str]`` rather than ``typing.Iterable[str]``,
etc.

For code which doesn't use type annotations, the appropriate type
argument can be passed explicitly to the decorator itself::

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add note to :func:`functools.singledispatch` documentation warning that
attempting to register an implementation with a deprecated alias from the
:mod:`typing` module is not supported.