-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document support for Python 3.6 features.
- Loading branch information
Guido van Rossum
committed
Oct 3, 2016
1 parent
a3b6546
commit 91a2275
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.. python36: | ||
New features in Python 3.6 | ||
========================== | ||
|
||
Python 3.6 will be `released | ||
<https://www.python.org/dev/peps/pep-0494>`_ in December 2016. The | ||
`first beta <https://www.python.org/downloads/release/python-360b1/>`_ | ||
came out in September and adds some exciting features. Here's the | ||
support matrix for these in mypy (to be updated with each new mypy | ||
release). The intention is to support all of these by the time Python | ||
3.6 is released. | ||
|
||
Syntax for variable annotations (`PEP 526 <https://www.python.org/dev/peps/pep-0526>`_) | ||
--------------------------------------------------------------------------------------- | ||
|
||
Python 3.6 feature: variables (in global, class or local scope) can | ||
now have type annotations using either of the two forms: | ||
|
||
.. code-block:: python | ||
foo: Optional[int] | ||
bar: List[str] = [] | ||
Mypy fully supports this syntax, interpreting them as equivalent to | ||
|
||
.. code-block:: python | ||
foo = None # type: Optional[int] | ||
bar = [] # type: List[str] | ||
Literal string formatting (`PEP 498 <https://www.python.org/dev/peps/pep-0498>`_) | ||
--------------------------------------------------------------------------------- | ||
|
||
Python 3.6 feature: string literals of the form | ||
``f"text {expression} text"`` evaluate ``expression`` using the | ||
current evaluation context (locals and globals). | ||
|
||
Mypy does not yet support this. | ||
|
||
Underscores in numeric literals (`PEP 515 <https://www.python.org/dev/peps/pep-0515>`_) | ||
--------------------------------------------------------------------------------------- | ||
|
||
Python 3.6 feature: numeric literals can contain underscores, | ||
e.g. ``1_000_000``. | ||
|
||
Mypy does not yet support this. | ||
|
||
Asynchronous generators (`PEP 525 <https://www.python.org/dev/peps/pep-0525>`_) | ||
------------------------------------------------------------------------------- | ||
|
||
Python 3.6 feature: coroutines defined with ``async def`` (PEP 492) | ||
can now also be generators, i.e. contain ``yield`` expressions. | ||
|
||
Mypy does not yet support this. | ||
|
||
Asynchronous comprehensions (`PEP 530 <https://www.python.org/dev/peps/pep-0530>`_) | ||
----------------------------------------------------------------------------------- | ||
|
||
Python 3.6 feature: coroutines defined with ``async def`` (PEP 492) | ||
can now also contain list, set and dict comprehensions that use | ||
``async for`` syntax. | ||
|
||
Mypy does not yet support this. |
91a2275
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require a custom
typed_ast
as implied in 5f0d02c?Just trying out mypy variable type annotation support using Python 3.6b2, and always get
Parse error before :
91a2275
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires
typed_ast >= 0.6.1
. (Trypython3 -m pip install --upgrade typed-ast
.)91a2275
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also,
--fast-parser
. I've added a note to the docs about this.91a2275
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic – thanks for the clarification + update @gvanrossum!