typed-ast is a Python 3 package that provided parsers for Python 2.7 and Python 3 (up to 3.7) Abstract Syntax Trees (ASTs). Unlike the standard `ast` module before Python 3.8, it included support for PEP 484 type comments and was independent of the Python version it was run on. The project is currently at version 1.5.5 and is no longer actively maintained, with recommendations to use the built-in `ast` module for Python 3.8+.
pip install typed-astVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates parsing Python 3 code containing PEP 484 type comments using `typed_ast.ast3.parse`. The `typed_ast` module was specifically designed to handle these comments, which the standard `ast` module in Python versions prior to 3.8 did not expose directly in the AST. For Python 3.8 and newer, the standard `ast` module can often be used instead.
For projects targeting Python 3.8 and newer, migrate to the standard library `ast` module. For projects requiring Python 3.7 or older, `typed-ast` may still be necessary, but be aware of its unmaintained status. Consider conditional imports or dropping support for older Python versions.
Ensure that the necessary C/C++ compiler toolchain is installed for your operating system (e.g., 'Desktop development with C++' workload for Visual Studio on Windows, `build-essential` on Debian/Ubuntu, or Xcode command line tools on macOS).
Carefully review the `typed-ast` source code or documentation (if available) for the specific AST node classes you are working with to understand any additional fields that need to be managed during AST construction or transformation.
Do not use `typed-ast` in environments running PyPy. Use CPython or an alternative AST parsing solution if PyPy compatibility is required.
No dependency data recorded yet.