New features in Python 3.6

Python 3.6 was released in December 2016. As of mypy 0.500 most language features new in Python 3.6 are supported, with the exception of asynchronous generators and comprehensions.

Syntax for variable annotations (PEP 526)

Python 3.6 feature: variables (in global, class or local scope) can now have type annotations using either of the two forms:

foo: Optional[int]
bar: List[str] = []

Mypy fully supports this syntax, interpreting them as equivalent to

foo = None  # type: Optional[int]
bar = []  # type: List[str]

Literal string formatting (PEP 498)

Python 3.6 feature: string literals of the form f"text {expression} text" evaluate expression using the current evaluation context (locals and globals).

Mypy fully supports this syntax and type-checks the expression.

Underscores in numeric literals (PEP 515)

Python 3.6 feature: numeric literals can contain underscores, e.g. 1_000_000.

Mypy fully supports this syntax:

precise_val = 1_000_000.000_000_1
hexes: List[int] = []

Asynchronous generators (PEP 525)

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)

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.

New named tuple syntax

Python 3.6 supports an alternative syntax for named tuples. See Named tuples.