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

arg_1 = 2
arg_2 = 3
func(arg_1, arg_2)
''')
>>> module.body[-1]
<Expr l.3 at 0x10ab46f28>
>>> inferred = next(module.body[-1].value.infer())
>>> inferred
<Const.int l.None at 0x10ab00588>
>>> inferred.value
5

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.

Support

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.