summaryrefslogtreecommitdiff
path: root/astroid/node_classes.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Ignore elements of sequences when converting them to AST with const_factoryClaudiu Popa2015-12-111-1/+11
| | | | | | | | | | | | | | | const_factory is buggy in master, as well as the entire raw_building module, which means that at given points during rebuilding of ASTs from live objects, nodes are constructed with Python objects as elements, leading to various crashes with pylint and with astroid during certain inference paths. This is fixed in 2.0 though, where raw_building was completely rewritten, but bringing those changes back into master will need some more work to be done. Until this happens, we ignore the elements of sequences passed to const_factory, since they are not useful in anyway (and the code that uses them crashes anyway). This is just a temporary solution until we either merge master with 2.0 or backport raw_building changes from 2.0 to master.
* Some nodes got a new attribute, 'ctx', which tells in which context the said ↵Claudiu Popa2015-12-081-0/+25
| | | | | | | | | | | | | | | | | | | 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.
* assigned_stmts methods have the same signature from now on.Claudiu Popa2015-12-051-2/+25
| | | | | | | 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.
* Merge structured exceptions into masterClaudiu Popa2015-11-231-8/+9
|\
| * Rename Uninferable and instatiate_classCeridwen2015-11-061-7/+7
| |
| * This bookmark adds structured exceptions to astroid.Ceridwen2015-11-021-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Major changes: * AstroidError has an __init__ that accepts arbitrary keyword-only arguments for adding information to exceptions, and a __str__ that lazily uses exception attributes to generate a message. The first positional argument to an exception is assigned to .message. The new API should be fully backwards compatible in general. * Some exceptions are combined or renamed; the old names are still available. * The OperationErrors used by pylint are now BadOperationMessages and located in util.py. * The AstroidBuildingException in _data_build stores the SyntaxError in its .error attribute rather than args[0]. * Many places where exceptions are raised have new, hopefully more useful error messages. The only major issue remaining is how to propagate information into decorators.
* | Handle the cases when a List can contain Uninferable as its elementsClaudiu Popa2015-11-231-0/+3
| | | | | | | | | | | | | | This can happen for instance when the list contains objects which weren't inferable in the first place. There were a bunch of places affected by this bug: unpack_infer, the inference of list additions and the handling of the namedtuple's fields.
* | Rename Uninferable and instantiate_class, fix broken tests, improveCeridwen2015-11-061-7/+7
|/ | | | | | | | | | | testing. * Rename YES to Uninferable * Rename instanciate_class to instantiate_class. * Use six in test_namedtuple_advanced_inference. * Fix test_file_from_module failure on PyPy. * Add enum34 to unittest_brain. * Add unittest_brain dependencies tox.ini.
* Fix Arguments' _other_fieldsCeridwen2015-10-121-1/+1
|
* Move proxy_alias function to util.pyClaudiu Popa2015-10-111-25/+8
|
* Move bases.NodeNG and bases.Statement in node_classesClaudiu Popa2015-10-111-55/+530
| | | | | | We're doing this in order to reduce the dependency hell which occurs when a module such as bases.py wants to use classes defined in node_classes.
* Add support for looking up into DictUnpack's value in Dict.getitemClaudiu Popa2015-10-061-0/+6
|
* Remove the value from the DictUnpack node, since it's used mostly to ↵Claudiu Popa2015-10-061-9/+1
| | | | represent the ** operation.
* Add a new node, DictUnpack, for representing the unpacking of a dict using ↵Claudiu Popa2015-10-061-0/+12
| | | | | | | | | 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.
* Remove trailing whitespace.Claudiu Popa2015-10-031-1/+1
|
* Move objects.Slice back into nodes.SliceClaudiu Popa2015-10-031-1/+33
| | | | | | We did this because objects.Slice had more capabilities than nodes.Slice, such as inferring the slice attributes (start, stop, step) and it was used mostly for inferring the slice() builtin.
* Hopefully actually fix #185Ceridwen2015-09-261-2/+2
|
* Make instancecheck a private function.Claudiu Popa2015-09-261-2/+2
|
* Add Call.starargs and Call.kwargs propertiesClaudiu Popa2015-09-121-0/+10
| | | | | | | They were added in order to have a minimum level of backward compatibility, since they were removed from the class. This is also an easy way to retrieve them, instead of looking explicitly for them in args or keywords respectively.
* Final draft of state printing after mergeCeridwen2015-09-131-7/+20
|\ | | | | | | | | | | | | | | | | | | | | | | | | This patch adds __str__` and `__repr__` methods to InferenceContext and alters the `__str__, `__repr__, and repr_tree() methods for NodeNG. The `__str__` methods print out formatted information about the object's fields; NodeNG's `__str__` method is not recursive. InferenceContext's __repr__` gives a compact representation of its fields. I slightly shortened NodeNG's `__repr__` method by removing a field that's usually empty. I rewrote repr_tree() to better format the information it contains and to display *all* the fields for each AST node, with some fields controlled by options to avoid spam. I also fixed https://bitbucket.org/logilab/astroid/issues/185/as_string-gives-wrong-result-for-keyword .
| * Second pass of the Python 3.5 support: adding Async nodes.Claudiu Popa2015-09-071-0/+18
| |
| * First pass of the Python 3.5 support.Claudiu Popa2015-09-071-7/+2
| |
* | Final draft of improved state printingCeridwen2015-09-131-3/+3
| |
* | First draft of improved state printingCeridwen2015-09-091-1/+1
|/
* Fix pylint issues.Claudiu Popa2015-08-251-0/+1
|
* Emit a warning when an old AST name is used in an isinstance call.Claudiu Popa2015-08-251-1/+8
|
* Use a stack level of 2 when emitting warnings, since the call site of the ↵Claudiu Popa2015-08-251-1/+1
| | | | deprecated method should be warned upon.
* Add deprecation warnings testsCeridwen2015-08-221-2/+2
|
* Last merge (hopefully) and all bugs fixed but oneCeridwen2015-08-211-75/+53
|\
| * Understand slices of tuples, lists, strings and instances with support for ↵Claudiu Popa2015-08-211-2/+13
| | | | | | | | | | | | slices. Closes issue #137.
| * Introduce a base class for Set, List and Tuple in order to avoid code ↵Claudiu Popa2015-08-201-42/+30
| | | | | | | | duplication. Closes issue #160.
* | Add tests for aliasesCeridwen2015-08-211-1/+7
| |
* | More fixes for bugs introduced during mergeCeridwen2015-08-181-1/+2
| |
* | More code review fixesCeridwen2015-08-151-4/+1
| |
* | Fix issues found in code reviewCeridwen2015-08-141-1/+1
| |
* | Fix most obvious errors intorduced by the latest mergeCeridwen2015-08-141-8/+1
| |
* | Merge main into defaultCeridwen2015-08-141-86/+101
|\ \ | |/
| * Big cleanup across the entire projectClaudiu Popa2015-08-121-77/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The cleanup consisted in a couple of changes: * import only modules, not objects, in order to not clutter the module namespace and to not leak accidentally objects which aren't public API for the said modules. * use two spaces between module level functions * move some mixins from astroid.node_classes in the proper order, starting at the left, not being last in the MRO.
| * Move InferenceContext and CallContext into astroid.contextClaudiu Popa2015-08-121-2/+3
| | | | | | | | | | | | | | In order to reduce circular dependencies between components, CallContext is moved into a new module, astroid.context. At the same time, for increasing the cohesion inside astroid.bases, InferenceContext was moved as well into astroid.context.
| * Move YES to astroid.util.Claudiu Popa2015-08-091-3/+4
| | | | | | | | | | | | | | YES is needed by other components of astroid, components which aren't necessarily related to astroid.bases. In order to reduce circular interdependencies between components, YES is moved into a new module, tailored for various *utilities*.
| * Add CallFunc.keywords, instead of putting together args and kwargs in ↵Claudiu Popa2015-08-081-4/+2
| | | | | | | | | | | | | | | | | | CallFunc.args This patch improves the similarity with the Python's AST. Until now, CallFunc.args contained both the positional arguments and the keyword arguments, which was misleading and always it was required to filter out keywords when working with arguments.
| * Get rid of astroid.common.decorators.Florian Bruhin2015-07-251-1/+1
| | | | | | | | | | | | | | | | This also implements an easier @cache decorator and removes @classproperty as it only was used in an insignificant test. --HG-- branch : no-logilab-common
* | Move proxies to nodes.py and scoped_nodes.pyCeridwen2015-07-131-0/+17
| |
* | Fix code review comments.Ceridwen2015-07-131-2/+1
| | | | | | | | | | | | | | | | Added aliases for inferred() and assign_type(), refactor some uses of ternary if, remove some now-unused internal functions in rebuilder, replaced the mutating docstring function with one that returns values as well as side-effects, change back to lazy-object-proxy, and add keyword args to the Module call in rebuilder.
* | Refactor node classes to have constructors and change some names.Ceridwen2015-07-101-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I corrected the spelling of 'infered' to 'infered' and changed some to make them more consistent with the built-in ast module and to read better in English. I created aliases with proxy objects to maintain backwards compatibility. I also refactored the node classes so that they have __init__ and postinit functions. The postinit function has to be called after the creation of a parent with the instances of its children because the node __init__ functions have to take a parent instance to maintain the doubly-linked structure of the AST. This involved moving considerable amounts of node-construction logic from rebuilder.py to node_classes.py and scoped_nodes.py.
* | Node constructors almost finished except for two bugsCeridwen2015-07-081-77/+371
|/
* Remove trailing whitespace.Claudiu Popa2015-07-011-1/+1
|
* Use six constants for python versions.Claudiu Popa2015-07-011-7/+3
|
* Add support for indexing bytes on Python 3.Claudiu Popa2015-07-011-0/+5
|
* Add annotation support for function.as_string(). Closes issue #37.Claudiu Popa2015-07-011-4/+6
|