astroid

An abstract syntax tree for Python with inference support.

187 个版本 Python >=3.10.0
安装
pip install astroid
poetry add astroid
pipenv install astroid
conda install astroid
描述

Astroid

.. image:: https://codecov.io/gh/pylint-dev/astroid/branch/main/graph/badge.svg :target: https://codecov.io/gh/pylint-dev/astroid :alt: Coverage badge from codecov

.. image:: https://readthedocs.org/projects/astroid/badge/?version=latest :target: http://astroid.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/ambv/black

.. image:: https://results.pre-commit.ci/badge/github/pylint-dev/astroid/main.svg :target: https://results.pre-commit.ci/latest/github/pylint-dev/astroid/main :alt: pre-commit.ci status

.. |tidelift_logo| image:: https://raw.githubusercontent.com/pylint-dev/astroid/main/doc/media/Tidelift_Logos_RGB_Tidelift_Shorthand_On-White.png :width: 200 :alt: Tidelift

.. list-table:: :widths: 10 100

    • |tidelift_logo|
    • Professional support for astroid is available as part of the Tidelift Subscription_. Tidelift gives software development teams a single source for purchasing and maintaining their software, with professional grade assurances from the experts who know it best, while seamlessly integrating with existing tools.

.. _Tidelift Subscription: https://tidelift.com/subscription/pkg/pypi-astroid?utm_source=pypi-astroid&utm_medium=referral&utm_campaign=readme

What's this?

The aim of this module is to provide a common base representation of python source code. It is currently the library powering pylint's capabilities.

It provides a compatible representation which comes from the _ast module. It rebuilds the tree generated by the builtin _ast module by recursively walking down the AST and building an extended ast. The new node classes have additional methods and attributes for different usages. They include some support for static inference and local name scopes. Furthermore, astroid can also build partial trees by inspecting living objects.

Installation

Extract the tarball, jump into the created directory and run::

pip install .

If you want to do an editable installation, you can run::

pip install -e .

If you have any questions, please mail the code-quality@python.org mailing list for support. See http://mail.python.org/mailman/listinfo/code-quality for subscription information and archives.

Documentation

http://astroid.readthedocs.io/en/latest/

Python Versions

astroid 2.0 is currently available for Python 3 only. If you want Python 2 support, use an older version of astroid (though note that these versions are no longer supported).

Test

Tests are in the 'test' subdirectory. To launch the whole tests suite, you can use either tox or pytest::

tox
pytest
版本列表
4.2.0b3 2026-04-24
4.2.0b2 2026-04-23
4.2.0b1 2026-03-23
4.1.2 2026-03-22
4.1.1 2026-02-23
4.1.0 2026-02-09
4.0.4 2026-02-07
4.0.3 2026-01-03
4.0.2 2025-11-09
4.0.1 2025-10-11
4.0.0 2025-10-05
4.0.0rc0 2025-09-29
4.0.0b3 2025-09-22
4.0.0b2 2025-08-07
4.0.0b1 2025-08-06
4.0.0b0 2025-07-27
4.0.0a0 2025-02-03
3.3.11 2025-07-13
3.3.10 2025-05-10
3.3.9 2025-03-09
3.3.8 2024-12-24
3.3.7 2024-12-21
3.3.6 2024-12-08
3.3.5 2024-10-04
3.3.4 2024-09-23
3.3.3 2024-09-20
3.3.2 2024-08-11
3.3.1 2024-08-06
3.3.0 2024-08-04
3.2.4 2024-07-20
3.2.3 2024-07-11
3.2.2 2024-05-19
3.2.1 2024-05-16
3.2.0 2024-05-07
3.1.0 2024-02-23
3.0.3 2024-02-04
3.0.2 2023-12-12
3.0.1 2023-10-16
3.0.0 2023-09-26
3.0.0b0 2023-09-24
3.0.0a9 2023-08-06
3.0.0a8 2023-07-15
3.0.0a7 2023-07-08
3.0.0a6 2023-07-04
3.0.0a5 2023-06-13
3.0.0a4 2023-06-06
3.0.0a3 2023-05-14
3.0.0a2 2023-04-25
3.0.0a1 2023-04-25
2.15.8 2023-09-26
2.15.7 2023-09-23
2.15.6 2023-07-08
2.15.5 2023-05-14
2.15.4 2023-04-24
2.15.3 2023-04-16
2.15.2 2023-04-03
2.15.1 2023-03-26
2.15.0 2023-03-05
2.14.2 2023-02-12
2.14.1 2023-01-31
2.14.0 2023-01-31
2.13.5 2023-01-31
2.13.4 2023-01-31
2.13.3 2023-01-20
2.13.2 2023-01-08
2.13.1 2023-01-08
2.13.0 2023-01-07
2.12.14 2023-01-06
2.12.13 2022-11-19
2.12.12 2022-10-19
2.12.11 2022-10-10
2.12.10 2022-09-17
2.12.9 2022-09-07
2.12.8 2022-09-06
2.12.7 2022-09-06
2.12.6 2022-09-05
2.12.5 2022-08-29
2.12.4 2022-08-25
2.12.3 2022-08-23
2.12.2 2022-07-12
2.12.1 2022-07-10
2.12.0 2022-07-09
2.11.7 2022-07-09
2.11.6 2022-06-13
2.11.5 2022-05-09
2.11.4 2022-05-02
2.11.3 2022-04-19
2.11.2 2022-03-26
2.11.1 2022-03-22
2.11.0 2022-03-12
2.10.0 2022-02-27
2.9.3 2022-01-09
2.9.2 2022-01-03
2.9.1 2021-12-31
2.9.0 2021-11-21
2.8.6 2021-11-21
2.8.5 2021-11-12
2.8.4 2021-10-25
2.8.3 2021-10-17
2.8.2 2021-10-07
2.8.2.dev0 2021-10-06
2.8.1 2021-10-07
2.8.0 2021-09-14
2.7.3 2021-08-30
2.7.2 2021-08-20
2.7.1 2021-08-16
2.7.0 2021-08-16
2.6.6 2021-08-03
2.6.5 2021-07-21
2.6.4 2021-07-19
2.6.3 2021-07-19
2.6.2 2021-06-30
2.6.1 2021-06-29
2.6.0 2021-06-22
2.6.0.dev0 2021-06-16
2.5.8 2021-06-07
2.5.7 2021-05-29
2.5.6 2021-04-25
2.5.5 2021-04-24
2.5.4 2021-04-24
2.5.3 2021-04-10
2.5.2 2021-03-28
2.5.1 2021-02-28
2.5 2021-02-15
2.4.2 2020-06-08
2.4.1 2020-05-05
2.4.0 2020-04-27
2.3.3 2019-11-06
2.3.2 2019-10-18
2.3.1 2019-09-30
2.3.0 2019-09-24
2.2.5 2019-03-08
2.2.4 2019-03-05
2.2.3 2019-03-04
2.2.2 2019-03-02
2.2.1 2019-03-02
2.2.0 2019-02-27
2.2.0.dev1 2019-02-20
2.2.0.dev0 2019-01-20
2.1.0 2018-11-25
2.1.0.dev0 2018-09-30
2.0.4 2018-08-10
2.0.3 2018-08-08
2.0.2 2018-08-01
2.0.1 2018-07-19
2.0.0.dev4 2018-07-05
2.0.0.dev3 2018-06-20
2.0.0.dev2 2018-06-19
2.0.0.dev1 2018-05-28
2.0.0.dev0 2018-05-21
2.0 2018-07-15
1.6.6 2019-04-09
1.6.5 2018-06-06
1.6.4 2018-05-15
1.6.3 2018-04-05
1.6.2 2018-03-16
1.6.1 2018-01-23
1.6.0 2017-12-15
1.5.3 2017-06-03
1.5.2 2017-04-17
1.5.1 2017-04-13
1.5.0 2017-04-13
1.4.9 2016-12-18
1.4.8 2016-07-26
1.4.7 2016-07-07
1.4.6 2016-06-06
1.4.5 2016-03-21
1.4.4 2016-01-15
1.4.3 2015-12-24
1.4.2 2015-12-21
1.4.1 2015-11-29
1.4.0 2015-11-29
1.3.8 2015-08-02
1.3.7 2015-07-27
1.3.6 2015-03-14
1.3.5 2015-03-11
1.3.4 2015-01-16
1.3.3 2015-01-16
1.3.2 2014-11-22
1.3.1 2014-11-21
1.3.0 2014-11-20
1.2.1 2014-08-24
1.2.0 2014-07-25
1.1.1 2014-04-30
1.1.0 2014-04-18
1.0.1 2013-10-18
1.0.0 2013-07-30