| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
node was used.
The possible values for the contexts are `Load` ('a'), `Del` ('del a'),
`Store` ('a = 4') and the nodes that got the new attribute are Starred,
Subscript, List and Tuple. The builtin ast module provides contexts for
Name and Attribute as well, but we took a different approach in the past,
by having different nodes for each type of context. For instance, Name
used in a Del context is a DelName, while Name used in a Store
context is AssignName. Since this is ingrained in astroid since quite
some time, it makes no sense to change them as well, even though it's
a loss of consistency.
The patch introduces a new dependency to enum34 on older Python
versions, which is used for building the three possible enum values
for the contexts.
Closes issue #267.
|
|
|
|
| |
import is trying to access something beyond the top-level package.
|
|
|
|
| |
The first name will exist until astroid 2.0.
|
|
|
|
|
|
|
|
| |
They are subclasses of AstroidBuildingException and are raised when
a module can't be imported from various reasons.
Also do_import_module lets the errors to bubble up without converting
them to InferenceError. This particular conversion happens only
during the inference.
|
|
|
|
|
|
|
| |
They used to have different signatures and each one made
assumptions about what could be passed to other implementations,
leading to various possible crashes when one or more arguments
weren't given. Closes issue #277.
|
| |
|
|
|
|
|
|
|
| |
to avoid a potential problem with encodings when using .format.
Closes issue #273.
|
|
|
|
|
|
|
|
| |
Also, Class.getattr('__bases__') returns actual bases.
It previously didn't work correctly, because it was putting the
entire ancestors into the Tuple object and it put those classes
into the wrong attribute.
Closes issue #128.
|
|
|
|
|
|
|
|
| |
__index__ returning-int method.
This patch moves _class_as_index to helpers, where it becames class_instance_as_index.
Also, it instantiates its own call context, which makes certain idioms with lambdas
to work.
|
|
|
|
|
|
|
|
|
| |
PEP 448
This is a different approach than what the builtin ast module does,
since it just uses None to represent this kind of operation,
which seems conceptually wrong, due to the fact the AST contains
non-AST nodes. Closes issue #206.
|
|
|
|
|
|
|
|
| |
Since astroid doesn't understand properly augmented assignments, we have
false positives with pylint when trying to find numpy attributes defined
in some submodules, since numpy and numpy.core generates the __all__
list by appending values from the subimport's __all__.
This should fix pylint's issue #453.
|
| |
|
|
|
|
|
|
|
|
| |
bases, attrs)``
Until now, inferring this kind of calls resulted in Instances, not in classes,
since astroid didn't understand that the presence of the metaclass in the call
leads to a class creationg, not to an instance creation.
|
| |
|
|
|
|
|
|
| |
slices.
Closes issue #137.
|
|
|
|
|
|
|
|
| |
Class.declared_metaclass.
Class.mro remains the de facto method for retrieving the metaclass
of a class, which will also do an evaluation of what declared_metaclass
returns.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Until now, the transforms were applied at the same time the tree was
being built. This was problematic if the transform functions were
using inference, since the inference was executed on a partially
constructed tree, which led to failures when post-building
information was needed (such as setting the _from_names
for the From imports).
Now there's a separate step for transforms, which are applied
using transform.TransformVisitor.
There's a couple of other related changes:
* astroid.parse and AstroidBuilder gained a new parameter
`apply_transforms`, which is a boolean flag, which will
control if the transforms are applied. We do this because
there are uses when the vanilla tree is wanted, without
any implicit modification.
* the transforms are also applied for builtin modules,
as a side effect of the fact that transform visiting
was moved in AstroidBuilder._post_build from
AstroidBuilder._data_build.
Closes issue #116.
|
|
|
|
|
|
| |
which is `type` on Python 3.
Closes issue #114.
|
|
|
|
| |
the class that wraps a node.
|
| |
|
|
|
|
|
|
|
|
|
| |
than 1.
This has the side effect that using `from .something import something`
in a non-package will finally result in an import-error on Pylint's side.
Until now relative_only was ignored, leading to the import of `something`,
if it was globally available.
|
|
|
|
|
|
| |
This API can be used to retrieve an astroid AST from a source code string,
similar to how ast.parse can be used to obtain a Python AST from a source string.
This is the test_utils.build_module promoted to a public API.
|
|
|
|
| |
#129.
|
|
|
|
|
| |
We moved astroid.manager.Project and astroid.manager.Manager.project_from_files
to pyreverse.inspector.
|
| |
|
|
|
|
| |
__getitem__. Closes issue #124.
|
| |
|
| |
|
|
|
|
| |
components. Closes issue #138.
|
|
|
|
| |
provides an __index__ returning-int method.
|
| |
|
|
|
|
|
|
|
|
|
| |
augmented assignments.
The change is similar to what was added for UnaryOps: a new method
called *type_errors* for both AugAssign and BinOp, which can be used
to retrieve type errors occurred during inference. Also, a new
exception object was added, BinaryOperationError.
|
|
|
|
|
|
| |
This patch completely changes the way how binary and augmented operations are
inferred, trying to be as compatible as possible with the semantics
from the language reference.
|
|
|
|
| |
if an object is a super/sub type of another.
|
|
|
|
|
| |
This uses the recently added *astroid.helpers.object_type* in order to
retrieve the Python type of the first argument of the call.
|
|
|
|
|
|
|
| |
yet into other components.
Added *object_type*, a function which can be used to obtain the type of almost any astroid object,
similar to how the builtin *type* works.
|
|
|
|
| |
Previously trying to infer the Name(NotImplemented) returned an YES object.
|
|
|
|
| |
details.
|
| |
|
| |
|
|
|
|
| |
pylint.pyreverse.utils.
|
|
|
|
|
|
|
| |
This was moved since it is the only known client of this module.
No other change was made to the exported API. This doesn't go
through a normal deprecation cycle, since I really want to clean it up
at a faster pace.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
It is used to deduce the value of a node when used in a boolean context, which is useful
for both inference, as well as for data flow analysis, where we are interested
in what branches will be followed when the program will be executed.
`bool_value` returns True, False or YES, if the node's boolean value can't
be deduced. The method is used when inferring the unary operand `not`.
Thus, `not something` will result in calling `something.bool_value` and
negating the result, if it is a boolean.
|
|
|
|
|
|
|
|
|
|
|
|
| |
operations.
In exceptions, one object was added for holding information about a possible
UnaryOp TypeError, object called `UnaryOperationError`. Even though the name
suggests it's an exception, it's actually not one. When inferring UnaryOps,
we use this special object to mark a possible TypeError,
object which can be interpreted by pylint in order to emit a new warning.
We are also exposing a new method for UnaryOps, called `type_errors`,
which returns a list of UnaryOperationsError.
|
|
|
|
|
|
| |
This patch improves especially the inferrence when using `from ... import ...`
syntax. Also, we added a new fail import hook for six.moves, which fixes the
import-error false positive from pylint. Closes issue #107.
|
|
|
|
|
|
| |
When inferring unary operands, astroid looks up the return value
of __pos__, __neg__ and __invert__ to determine the inferred value
of ``~node``, ``+node`` or ``-node``.
|
| |
|
| |
|