Welcome to astroid’s documentation!

astroid is a library for AST parsing, static analysis and inference, currently powering most of pylint capabilities.

It offers support for parsing Python source code into ASTs, similar to how the builtin ast module works. On top of that, it can partially infer various Python constructs, as seen in the following example:

from astroid import parse
module = parse('''
def func(first, second):
    return first + second

func(first, second)
>>> module.body[-1]
<Expr l.3 at 0x10ab46f28>
>>> inferred = next(a.body[-1].value.infer())
>>> inferred
<Const.int l.None at 0x10ab00588>
>>> inferred.value

astroid also allows the user to write various inference transforms for enhancing its Python understanding, helping as well pylint in the process of figuring out the dynamic nature of Python.


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.

Indices and tables