@@ -5,9 +5,8 @@ New features in Python 3.6
5
5
6
6
Python 3.6 was `released
7
7
<https://www.python.org/downloads/release/python-360/> `_ in
8
- December 2016. As of mypy 0.500 most language features new in Python
9
- 3.6 are supported, with the exception of asynchronous generators and
10
- comprehensions.
8
+ December 2016. As of mypy 0.510 all language features new in Python
9
+ 3.6 are supported.
11
10
12
11
Syntax for variable annotations (`PEP 526 <https://www.python.org/dev/peps/pep-0526 >`_)
13
12
---------------------------------------------------------------------------------------
@@ -50,22 +49,20 @@ Mypy fully supports this syntax:
50
49
hexes: List[int ] = []
51
50
hexes.append(0x _FF_FF_FF_FF )
52
51
53
- Asynchronous generators (`PEP 525 <https://www.python.org/dev/peps/pep-0525 >`_)
54
- -------------------------------------------------------------------------------
52
+ Asynchronous generators (`PEP 525 <https://www.python.org/dev/peps/pep-0525 >`_) and comprehensions (` PEP 530 < https://www.python.org/dev/peps/pep-0530 >`_)
53
+ ----------------------------------------------------------------------------------------------------------------------------------------------------------
55
54
56
- Python 3.6 feature: coroutines defined with ``async def `` (PEP 492)
57
- can now also be generators, i.e. contain ``yield `` expressions.
55
+ Python 3.6 allows coroutines defined with ``async def `` (PEP 492) to be
56
+ generators, i.e. contain ``yield `` expressions, and introduces a syntax for
57
+ asynchronous comprehensions. Mypy fully supports these features, for example:
58
58
59
- Mypy does not yet support this.
60
-
61
- Asynchronous comprehensions (`PEP 530 <https://www.python.org/dev/peps/pep-0530 >`_)
62
- -----------------------------------------------------------------------------------
59
+ .. code-block :: python
63
60
64
- Python 3.6 feature: coroutines defined with ``async def `` (PEP 492)
65
- can now also contain list, set and dict comprehensions that use
66
- ``async for `` syntax.
61
+ from typing import AsyncIterator
67
62
68
- Mypy does not yet support this.
63
+ async def gen () -> AsyncIterator[bytes ]:
64
+ lst = [b async for b in gen()] # Inferred type is "List[bytes]"
65
+ yield ' no way' # Error: Incompatible types (got "str", expected "bytes")
69
66
70
67
New named tuple syntax
71
68
----------------------
0 commit comments