summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorkj <28750310+Fidget-Spinner@users.noreply.github.com>2020-11-19 17:37:26 (GMT)
committerGitHub <noreply@github.com>2020-11-19 17:37:26 (GMT)
commite1dc0db8c7cb8c4d7343e051ba85146b375bb8e0 (patch)
tree09a88141998e4d57fe2dcb5ae12adca34c1f2efd /Doc/whatsnew
parent1b54077ff6f5c1379e097e9f8e8648da9826d6ec (diff)
downloadcpython-e1dc0db8c7cb8c4d7343e051ba85146b375bb8e0.zip
cpython-e1dc0db8c7cb8c4d7343e051ba85146b375bb8e0.tar.gz
cpython-e1dc0db8c7cb8c4d7343e051ba85146b375bb8e0.tar.bz2
bpo-42345: Add whatsnew and versionchanged for typing.Literal in 3.9 (GH-23386)
* Whatsnew entry in 3.9 same as the one in 3.10. * versionchanged for typing.Literal docs Needs backport to 3.9.
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/3.9.rst29
1 files changed, 29 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index a601b16..b89faf1 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -1454,3 +1454,32 @@ Removed
``PyNullImporter_Type``, ``PyCmpWrapper_Type``, ``PySortWrapper_Type``,
``PyNoArgsFunction``.
(Contributed by Pablo Galindo Salgado in :issue:`39372`.)
+
+Notable changes in Python 3.9.1
+===============================
+
+typing
+------
+
+The behavior of :class:`typing.Literal` was changed to conform with :pep:`586`
+and to match the behavior of static type checkers specified in the PEP.
+
+1. ``Literal`` now de-duplicates parameters.
+2. Equality comparisons between ``Literal`` objects are now order independent.
+3. ``Literal`` comparisons now respect types. For example,
+ ``Literal[0] == Literal[False]`` previously evaluated to ``True``. It is
+ now ``False``. To support this change, the internally used type cache now
+ supports differentiating types.
+4. ``Literal`` objects will now raise a :exc:`TypeError` exception during
+ equality comparisons if one of their parameters are not :term:`immutable`.
+ Note that declaring ``Literal`` with mutable parameters will not throw
+ an error::
+
+ >>> from typing import Literal
+ >>> Literal[{0}]
+ >>> Literal[{0}] == Literal[{False}]
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ TypeError: unhashable type: 'set'
+
+(Contributed by Yurii Karabas in :issue:`42345`.) \ No newline at end of file