String annotations [PEP 563] (#4390)

* Document `from __future__ import annotations`
* Provide plumbing and tests for `from __future__ import annotations`
* Implement unparsing the AST back to string form

This is required for PEP 563 and as such only implements a part of the
unparsing process that covers expressions.
This commit is contained in:
Guido van Rossum 2018-01-26 08:20:18 -08:00 committed by Łukasz Langa
parent d7773d92bd
commit 95e4d58913
16 changed files with 1476 additions and 29 deletions

View file

@ -853,12 +853,15 @@ can appear before a future statement are:
* blank lines, and
* other future statements.
.. XXX change this if future is cleaned out
The only feature in Python 3.7 that requires using the future statement is
``annotations``.
The features recognized by Python 3.0 are ``absolute_import``, ``division``,
``generators``, ``unicode_literals``, ``print_function``, ``nested_scopes`` and
``with_statement``. They are all redundant because they are always enabled, and
only kept for backwards compatibility.
All historical features enabled by the future statement are still recognized
by Python 3. The list includes ``absolute_import``, ``division``,
``generators``, ``generator_stop``, ``unicode_literals``,
``print_function``, ``nested_scopes`` and ``with_statement``. They are
all redundant because they are always enabled, and only kept for
backwards compatibility.
A future statement is recognized and treated specially at compile time: Changes
to the semantics of core constructs are often implemented by generating