diff options
author | Bas van Beek <43369155+BvB93@users.noreply.github.com> | 2020-09-22 15:55:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-22 15:55:34 (GMT) |
commit | 0d0e9fe2ffc1683758a1985ef6dedeef5ecafdbc (patch) | |
tree | 6b8cf4e733d804aaf7f841c0d37d48edff7b710d /Doc | |
parent | a68a2ad19c891faa891904b3da537911cc77df21 (diff) | |
download | cpython-0d0e9fe2ffc1683758a1985ef6dedeef5ecafdbc.zip cpython-0d0e9fe2ffc1683758a1985ef6dedeef5ecafdbc.tar.gz cpython-0d0e9fe2ffc1683758a1985ef6dedeef5ecafdbc.tar.bz2 |
bpo-41810: Reintroduce `types.EllipsisType`, `.NoneType` & `.NotImplementedType` (GH-22336)
closes issue 41810
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/constants.rst | 13 | ||||
-rw-r--r-- | Doc/library/types.rst | 21 | ||||
-rw-r--r-- | Doc/whatsnew/3.10.rst | 8 |
3 files changed, 37 insertions, 5 deletions
diff --git a/Doc/library/constants.rst b/Doc/library/constants.rst index f17e1a3..38dd552 100644 --- a/Doc/library/constants.rst +++ b/Doc/library/constants.rst @@ -19,19 +19,21 @@ A small number of constants live in the built-in namespace. They are: .. data:: None - The sole value of the type ``NoneType``. ``None`` is frequently used to - represent the absence of a value, as when default arguments are not passed to a - function. Assignments to ``None`` are illegal and raise a :exc:`SyntaxError`. + An object frequently used to represent the absence of a value, as when + default arguments are not passed to a function. Assignments to ``None`` + are illegal and raise a :exc:`SyntaxError`. + ``None`` is the sole instance of the :data:`NoneType` type. .. data:: NotImplemented - Special value which should be returned by the binary special methods + A special value which should be returned by the binary special methods (e.g. :meth:`__eq__`, :meth:`__lt__`, :meth:`__add__`, :meth:`__rsub__`, etc.) to indicate that the operation is not implemented with respect to the other type; may be returned by the in-place binary special methods (e.g. :meth:`__imul__`, :meth:`__iand__`, etc.) for the same purpose. It should not be evaluated in a boolean context. + ``NotImplemented`` is the sole instance of the :data:`types.NotImplementedType` type. .. note:: @@ -59,8 +61,9 @@ A small number of constants live in the built-in namespace. They are: .. index:: single: ...; ellipsis literal .. data:: Ellipsis - The same as the ellipsis literal "``...``". Special value used mostly in conjunction + The same as the ellipsis literal "``...``". Special value used mostly in conjunction with extended slicing syntax for user-defined container data types. + ``Ellipsis`` is the sole instance of the :data:`types.EllipsisType` type. .. data:: __debug__ diff --git a/Doc/library/types.rst b/Doc/library/types.rst index 79acdf4..25fa750 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -103,6 +103,13 @@ If you instantiate any of these types, note that signatures may vary between Pyt Standard names are defined for the following types: +.. data:: NoneType + + The type of :data:`None`. + + .. versionadded:: 3.10 + + .. data:: FunctionType LambdaType @@ -186,6 +193,13 @@ Standard names are defined for the following types: .. versionadded:: 3.7 +.. data:: NotImplementedType + + The type of :data:`NotImplemented`. + + .. versionadded:: 3.10 + + .. data:: MethodDescriptorType The type of methods of some built-in data types such as :meth:`str.join`. @@ -236,6 +250,13 @@ Standard names are defined for the following types: Defaults to ``None``. Previously the attribute was optional. +.. data:: EllipsisType + + The type of :data:`Ellipsis`. + + .. versionadded:: 3.10 + + .. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno) The type of traceback objects such as found in ``sys.exc_info()[2]``. diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index ce888fe..f88281a 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -145,6 +145,14 @@ Add :data:`sys.orig_argv` attribute: the list of the original command line arguments passed to the Python executable. (Contributed by Victor Stinner in :issue:`23427`.) +types +----- + +Reintroduced the :data:`types.EllipsisType`, :data:`types.NoneType` +and :data:`types.NotImplementedType` classes, providing a new set +of types readily interpretable by type checkers. +(Contributed by Bas van Beek in :issue:`41810`.) + unittest -------- |