1# Copyright (c) 2006-2013, 2015 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr>
2# Copyright (c) 2014 Google, Inc.
3# Copyright (c) 2014 Eevee (Alex Munroe) <amunroe@yelp.com>
4# Copyright (c) 2015-2016, 2018, 2020 Claudiu Popa <pcmanticore@gmail.com>
5# Copyright (c) 2015-2016 Ceridwen <ceridwenv@gmail.com>
6# Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com>
7# Copyright (c) 2016 Moises Lopez <moylop260@vauxoo.com>
8# Copyright (c) 2018 Bryce Guinta <bryce.paul.guinta@gmail.com>
9# Copyright (c) 2019 Nick Drozd <nicholasdrozd@gmail.com>
10# Copyright (c) 2020-2021 hippo91 <guillaume.peillex@gmail.com>
11# Copyright (c) 2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>
12# Copyright (c) 2021 Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
13# Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>
14
15# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
16# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
17
18"""Python Abstract Syntax Tree New Generation
19
20The aim of this module is to provide a common base representation of
21python source code for projects such as pychecker, pyreverse,
22pylint... Well, actually the development of this library is essentially
23governed by pylint's needs.
24
25It extends class defined in the python's _ast module with some
26additional methods and attributes. Instance attributes are added by a
27builder object, which can either generate extended ast (let's call
28them astroid ;) by visiting an existent ast tree or by inspecting living
29object. Methods are added by monkey patching ast classes.
30
31Main modules are:
32
33* nodes and scoped_nodes for more information about methods and
34  attributes added to different node classes
35
36* the manager contains a high level object to get astroid trees from
37  source files and living objects. It maintains a cache of previously
38  constructed tree for quick access
39
40* builder contains the class responsible to build astroid trees
41"""
42
43from importlib import import_module
44from pathlib import Path
45
46# isort: off
47# We have an isort: off on '__version__' because the packaging need to access
48# the version before the dependencies are installed (in particular 'wrapt'
49# that is imported in astroid.inference)
50from astroid.__pkginfo__ import __version__, version
51from astroid.nodes import node_classes, scoped_nodes
52
53# isort: on
54
55from astroid import inference, raw_building
56from astroid.astroid_manager import MANAGER
57from astroid.bases import BaseInstance, BoundMethod, Instance, UnboundMethod
58from astroid.brain.helpers import register_module_extender
59from astroid.builder import extract_node, parse
60from astroid.const import Context, Del, Load, Store
61from astroid.exceptions import *
62from astroid.inference_tip import _inference_tip_cached, inference_tip
63from astroid.objects import ExceptionInstance
64
65# isort: off
66# It's impossible to import from astroid.nodes with a wildcard, because
67# there is a cyclic import that prevent creating an __all__ in astroid/nodes
68# and we need astroid/scoped_nodes and astroid/node_classes to work. So
69# importing with a wildcard would clash with astroid/nodes/scoped_nodes
70# and astroid/nodes/node_classes.
71from astroid.nodes import (  # pylint: disable=redefined-builtin (Ellipsis)
72    CONST_CLS,
73    AnnAssign,
74    Arguments,
75    Assert,
76    Assign,
77    AssignAttr,
78    AssignName,
79    AsyncFor,
80    AsyncFunctionDef,
81    AsyncWith,
82    Attribute,
83    AugAssign,
84    Await,
85    BinOp,
86    BoolOp,
87    Break,
88    Call,
89    ClassDef,
90    Compare,
91    Comprehension,
92    ComprehensionScope,
93    Const,
94    Continue,
95    Decorators,
96    DelAttr,
97    Delete,
98    DelName,
99    Dict,
100    DictComp,
101    DictUnpack,
102    Ellipsis,
103    EmptyNode,
104    EvaluatedObject,
105    ExceptHandler,
106    Expr,
107    ExtSlice,
108    For,
109    FormattedValue,
110    FunctionDef,
111    GeneratorExp,
112    Global,
113    If,
114    IfExp,
115    Import,
116    ImportFrom,
117    Index,
118    JoinedStr,
119    Keyword,
120    Lambda,
121    List,
122    ListComp,
123    Match,
124    MatchAs,
125    MatchCase,
126    MatchClass,
127    MatchMapping,
128    MatchOr,
129    MatchSequence,
130    MatchSingleton,
131    MatchStar,
132    MatchValue,
133    Module,
134    Name,
135    NamedExpr,
136    NodeNG,
137    Nonlocal,
138    Pass,
139    Raise,
140    Return,
141    Set,
142    SetComp,
143    Slice,
144    Starred,
145    Subscript,
146    TryExcept,
147    TryFinally,
148    Tuple,
149    UnaryOp,
150    Unknown,
151    While,
152    With,
153    Yield,
154    YieldFrom,
155    are_exclusive,
156    builtin_lookup,
157    unpack_infer,
158    function_to_method,
159)
160
161# isort: on
162
163from astroid.util import Uninferable
164
165# load brain plugins
166ASTROID_INSTALL_DIRECTORY = Path(__file__).parent
167BRAIN_MODULES_DIRECTORY = ASTROID_INSTALL_DIRECTORY / "brain"
168for module in BRAIN_MODULES_DIRECTORY.iterdir():
169    if module.suffix == ".py":
170        import_module(f"astroid.brain.{module.stem}")
171