Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 5, 2023. It is now read-only.
/typed_astPublic archive

Modified fork of CPython's ast module that parses `# type:` comments

License

NotificationsYou must be signed in to change notification settings

python/typed_ast

Repository files navigation

This project is no longer maintained.

Use the standard libraryast module instead.See#179.

Typed AST

Build StatusChat at https://gitter.im/python/typed_ast

typed_ast is a Python 3 package that provides a Python 2.7 and Python 3parser similar to the standardast library. Unlikeast up to Python 3.7, the parsers intyped_ast includePEP 484 typecomments and are independent of the version of Python under which they are run.Thetyped_ast parsers produce the standard Python AST (plus type comments),and are both fast and correct, as they are based on the CPython 2.7 and 3.7parsers.typed_ast runs on CPython 3.6-3.10 on Linux, OS X and Windows.

Note: Starting with Python 3.8, we recommend to use the nativeast parser(see below).

Development Philosophy

This project is a (mostly) drop-in replacement for the builtinast module. It isintended to be bug-for-bug compatible and behave identically, except for thepresence of a few additional fields on the returned classes and a fewadditional optional arguments to theparse call. Therefore,typed_ast willnot accept any bugfixes for bugs inast -- they should be fixed upstreaminstead. To avoid feature bloat, any new features fortyped_ast should havethe potential to be broadly useful and not be built just for one niche usecaseor in a manner such that only one project can use them.

Incompatibilities

For the purposes ofconsuming syntax trees, this should be a drop-in replacement.It is not a drop-in replacement for users that wish to create or transform ASTs,as a number of syntax tree classes have additional fields that must be populatedwhen constructing them.

Due to reliance on certain C APIs, this library does not build on and thereareno plans to support PyPy.

Python 3.8

typed_ast will not be updated to support parsing Python 3.8 andnewer. Instead, it is recommended to use the stdlibast modulethere, which has been augmented to support extracting type commentsand has limited support for parsing older versions of Python 3.

Submodules

ast3

Theast3 parser produces the AST from a Python 3 code, up to Python 3.7.(For rationale and technicaldetails, seehere.) The AST it currently produces is described inast3/Parser/Python.asdl. If you wish to limitparsing to older versions of Python 3,ast3 can be configured to to give aSyntaxError for new syntax features introduced beyond a given Python version.For more information, see the module docstring intyped_ast/ast3.py.

ast27

Theast27 parser tracks the standard Python 2.7 AST, which is expected tonever receive further updates. The AST it produces is described inast27/Parser/Python.asdl. For more information,see the module docstring intyped_ast/ast27.py.

conversions

typed_ast also provides aconversions module which convertsast27 ASTsintoast3 ASTs. This functionality is somewhat experimental, however. Formore information, see thepy2to3 docstring intyped_ast/conversions.

Note: as these parsers consider type comments part of the grammar, incorrectlyplaced type comments are considered syntax errors.

Releases

To make a newtyped_ast release, seerelease_process.md.

About

Modified fork of CPython's ast module that parses `# type:` comments

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors27


[8]ページ先頭

©2009-2025 Movatter.jp