This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

The typed-astunparse is to typed-ast as astunparse is to ast. In short: unparsing of Python 3.5 abstract syntax trees (AST) with type comments.

The built-in ast module has capabilites to parse Python source code into AST. It does not, however, have the capability to generate source code from the AST. That’s where astunparse comes in. Using a refactored version of an obscure script found in official Python repository, it provides code generation capability for built-in AST.

Built-in ast module, however, completely ignores type comments introduced in PEP 484. It treats them like all other comments, so when you parse the code using compile(), your type comments will be lost. The typed-ast module intoduces AST and parser that includes type comments defined in PEP 484.

Unfortunately, typed-ast also doesn’t provide any means to go from AST to source code. This is where this module, typed-astunparse, comes in. It provides unparser for AST defined in typed-ast.


This package is intendended for Python 3.5. It was tested on 64 bit Ubuntu, but it might work on other systems too.

typed-astunparse depends on:

  • astunparse
  • typed-ast


For simplest installation use pip:

pip3.5 install typed-astunparse

You can also build your own version:

git clone
cd typed-astunparse
python3.5 -m unittest discover # make sure the tests pass
python3.5 bdist_wheel
ls -1tr dist/*.whl | tail -n 1 | xargs pip3.5 install


Example of roundtrip from code through AST to code:

import typed_ast
import typed_astunparse

code = 'my_string = None # type: str'
roundtrip = typed_astunparse.unparse(typed_ast.parse(code))

for more examples see examples.ipynb notebook.

Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
typed_astunparse-0.1.0-py3-none-any.whl (11.2 kB) Copy SHA256 Checksum SHA256 3.5 Wheel Jun 22, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting