From: Jelle Zijlstra Date: Tue, 4 May 2021 08:54:12 +0000 (-0700) Subject: bpo-44001: improve Literal documentation (GH-25877) X-Git-Tag: v3.11.0a1~1217 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=87109f4d85c93a870ee8aa0d2b394547d4636b17;p=thirdparty%2FPython%2Fcpython.git bpo-44001: improve Literal documentation (GH-25877) --- diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 8b1ce34d98ec..ba79bb7ed75f 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -799,10 +799,10 @@ These can be used as types in annotations using ``[]``, each having a unique syn .. versionadded:: 3.8 .. versionchanged:: 3.9.1 - ``Literal`` now de-duplicates parameters. Equality comparison of + ``Literal`` now de-duplicates parameters. Equality comparisons of ``Literal`` objects are no longer order dependent. ``Literal`` objects will now raise a :exc:`TypeError` exception during equality comparisons - if one of their parameters are not :term:`immutable`. + if one of their parameters are not :term:`hashable`. .. data:: ClassVar diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index eb452b07f55f..3d5a18862581 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -1271,8 +1271,8 @@ and to match the behavior of static type checkers specified in the PEP. 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 + equality comparisons if any of their parameters are not :term:`hashable`. + Note that declaring ``Literal`` with unhashable parameters will not throw an error:: >>> from typing import Literal diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 772fb5a3fe74..f1725e7df022 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -1494,7 +1494,7 @@ and to match the behavior of static type checkers specified in the PEP. 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`. + equality comparisons if any of their parameters are not :term:`hashable`. Note that declaring ``Literal`` with mutable parameters will not throw an error::