summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-06-11 21:13:25 (GMT)
committerGitHub <noreply@github.com>2019-06-11 21:13:25 (GMT)
commit785688832de699270530a9418e99c5c4caedbffb (patch)
treeee7c2313fdaa355a1ae4e2a20d1d1d29af46df4d /Doc/whatsnew
parent83abd9658b4845299452be06c9ce92cbceee944d (diff)
downloadcpython-785688832de699270530a9418e99c5c4caedbffb.zip
cpython-785688832de699270530a9418e99c5c4caedbffb.tar.gz
cpython-785688832de699270530a9418e99c5c4caedbffb.tar.bz2
bpo-35766: What's new in the ast and typing modules (GH-13984)
(cherry picked from commit 9b33ce48a7846dbdad32d4f8936b08e6b78a2faf) Co-authored-by: Guido van Rossum <guido@python.org>
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/3.8.rst46
1 files changed, 46 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 8456a17..64e2e8e 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -337,6 +337,29 @@ Improved Modules
================
+ast
+---
+
+AST nodes now have ``end_lineno`` and ``end_col_offset`` attributes,
+which give the precise location of the end of the node. (This only
+applies to nodes that have ``lineno`` and ``col_offset`` attributes.)
+
+The :func:`ast.parse` function has some new flags:
+
+* ``type_comments=True`` causes it to return the text of :pep:`484` and
+ :pep:`526` type comments associated with certain AST nodes;
+
+* ``mode='func_type'`` can be used to parse :pep:`484` "signature type
+ comments" (returned for function definition AST nodes);
+
+* ``feature_version=N`` allows specifying the minor version of an
+ earlier Python 3 version. (For example, ``feature_version=4`` will
+ treat ``async`` and ``await`` as non-reserved words.)
+
+New function :func:`ast.get_source_segment` returns the source code
+for a specific AST node.
+
+
asyncio
-------
@@ -736,6 +759,29 @@ time
Added new clock :data:`~time.CLOCK_UPTIME_RAW` for macOS 10.12.
(Contributed by Joannah Nanjekye in :issue:`35702`.)
+
+typing
+------
+
+The :mod:`typing` module incorporates several new features:
+
+* Protocol definitions. See :pep:`544`, :class:`typing.Protocol` and
+ :func:`typing.runtime_checkable`. Simple ABCs like
+ :class:`typing.SupportsInt` are now ``Protocol`` subclasses.
+
+* A dictionary type with per-key types. See :pep:`589` and
+ :class:`typing.TypedDict`.
+
+* Literal types. See :pep:`586` and :class:`typing.Literal`.
+
+* "Final" variables, functions, methods and classes. See :pep:`591`,
+ :class:`typing.Final` and :func:`typing.final`.
+
+* New protocol class :class:`typing.SupportsIndex`.
+
+* New functions :func:`typing.get_origin` and :func:`typing.get_args`.
+
+
unicodedata
-----------