| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The old way consisted in having the parameter names, their
defaults and their annotations separated in different components
of the Arguments node. We introduced a new Param node, which holds
the name of a parameter, its default value and its annotation.
If any of the last two values are missing, then that slot will be
filled with a new node kind, Empty, which is used for specifying the
lack of something (None could have been used instead, but that means having
non-AST nodes in the Arguments node).
We're also having support for positional only arguments, for the moment
only in raw_building.
Close #215
|
| | |
|
| |
|
|
|
| |
This should prevent a StopIteration leaking when next is called
over unpack_infer.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
When looking up a name in a scope, Scope.lookup will return
only the values which will be reachable after execution, as seen
in the following code:
a = 1
a = 2
In this case it doesn't make sense to return two values, but
only the last one.
|
| |
|
|
|
|
|
|
| |
Dict was a bit different that the corresponding class from the
builtin ast module with respect to how it was initialized.
Instead of accepting a list of pairs, the initializer accepts
two arguments, one for keys, the other for values. For backward
compatibility, the class gained a new .items property.
|
| |
|
|
|
|
| |
This means that checks such as ``isinstance(node, Lambda)`` will not
hold true anymore for Functions.
Closes #291
|
| |
|
|
|
|
| |
The mixins are better off in tree.base, rather than having their
own module. They are also used only by the AST nodes.
Close #292
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
do_import_module was broken for Import, since it was relying on a
missing attribute `modname`. do_import_module
in fact required all the time for a name parameter to be
passed as an argument. The inherent problem is that
Import doesn't have an underlying module name, but more of them,
in the .names attribute. Thus requiring for do_import_module to
pick one name from .names or to return multiple modules was
deemed inappropiate and the method became a function which
always requires the import name to be given.
do_import_module and real_name are now functions in interpreter.util.
Closes #293
|
| | |
|
| |
|
|
|
|
|
|
| |
current and parent slots.
We're doing this because this is the right semantics of slots,
they get inherited, as long as each parent defines a __slots__
entry.
|
| | |
|
| |
|
|
| |
problem with encodings when using .format.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
| |
removed in 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.
|
| |
|
|
|
|
| |
This bug occurs when the left hand side of an assignment has an extra element
comparing with the right hand side, which makes the Starred node to not be inferred
correctly as an empty List. Closes issue #239.
|
| |
|
|
| |
annotations and comprehensions. Closes issue #211.
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
--HG--
branch : no-logilab-common
|
| |
|
|
|
|
|
|
|
| |
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.
|