| 1 |
.. Astroid documentation main file, created by |
| 2 |
sphinx-quickstart on Wed Jun 26 15:00:40 2013. |
| 3 |
You can adapt this file completely to your liking, but it should at least |
| 4 |
contain the root `toctree` directive. |
| 5 |
|
| 6 |
.. Please see the documentation for the Sphinx Python domain : |
| 7 |
http://sphinx-doc.org/domains.html#the-python-domain |
| 8 |
and the autodoc extension |
| 9 |
http://sphinx-doc.org/ext/autodoc.html |
| 10 |
|
| 11 |
|
| 12 |
Welcome to astroid's documentation! |
| 13 |
=================================== |
| 14 |
|
| 15 |
**astroid** is a library for AST parsing, static analysis and inference, |
| 16 |
currently powering most of **pylint** capabilities. |
| 17 |
|
| 18 |
It offers support for parsing Python source code into ASTs, similar to how |
| 19 |
the builtin **ast** module works. On top of that, it can partially infer various |
| 20 |
Python constructs, as seen in the following example:: |
| 21 |
|
| 22 |
from astroid import parse |
| 23 |
module = parse(''' |
| 24 |
def func(first, second): |
| 25 |
return first + second |
| 26 |
|
| 27 |
arg_1 = 2 |
| 28 |
arg_2 = 3 |
| 29 |
func(arg_1, arg_2) |
| 30 |
''') |
| 31 |
>>> module.body[-1] |
| 32 |
<Expr l.3 at 0x...> |
| 33 |
>>> inferred = next(module.body[-1].value.infer()) |
| 34 |
>>> inferred |
| 35 |
<Const.int l.None at 0x...> |
| 36 |
>>> inferred.value |
| 37 |
5 |
| 38 |
|
| 39 |
|
| 40 |
**astroid** also allows the user to write various inference transforms for |
| 41 |
enhancing its Python understanding, helping as well **pylint** in the process |
| 42 |
of figuring out the dynamic nature of Python. |
| 43 |
|
| 44 |
Support |
| 45 |
------- |
| 46 |
|
| 47 |
.. image:: media/Tidelift_Logos_RGB_Tidelift_Shorthand_On-White.png |
| 48 |
:width: 75 |
| 49 |
:alt: Tidelift |
| 50 |
:align: left |
| 51 |
:class: tideliftlogo |
| 52 |
|
| 53 |
Professional support for astroid is available as part of the `Tidelift |
| 54 |
Subscription`_. Tidelift gives software development teams a single source for |
| 55 |
purchasing and maintaining their software, with professional grade assurances |
| 56 |
from the experts who know it best, while seamlessly integrating with existing |
| 57 |
tools. |
| 58 |
|
| 59 |
.. _Tidelift Subscription: https://tidelift.com/subscription/pkg/pypi-astroid?utm_source=pypi-astroid&utm_medium=referral&utm_campaign=readme |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
.. toctree:: |
| 64 |
:maxdepth: 2 |
| 65 |
:hidden: |
| 66 |
|
| 67 |
inference |
| 68 |
|
| 69 |
extending |
| 70 |
|
| 71 |
api/index |
| 72 |
|
| 73 |
whatsnew |
| 74 |
|
| 75 |
.. toctree:: |
| 76 |
:hidden: |
| 77 |
:caption: Indices |
| 78 |
|
| 79 |
genindex |
| 80 |
|
| 81 |
modindex |