summaryrefslogtreecommitdiff
path: root/astroid/objects.py
Commit message (Collapse)AuthorAgeFilesLines
* Protect against ``infer_call_result`` failing with `InferenceError` in ↵Claudiu Popa2020-05-011-1/+6
| | | | | | | | `Super.getattr()` (#782) ``infer_call_result`` can raise InferenceError but we were not handling that when retrieving objects from the Super instance. Close PyCQA/pylint#3529
* Add missing copyright annotations for the past releasesClaudiu Popa2020-04-271-1/+2
|
* Reverse super call with setting the function to allow string representation ↵Claudiu Popa2020-03-061-1/+1
| | | | before setting locals
* Add support for inferring propertiesClaudiu Popa2019-12-041-0/+26
| | | | | These new capabilities will allow inferring both the `property` builtin as well as property attributes such as `.deleter` and `.setter`.
* Correctly instantiate exception instances when inferring their attributes ↵Claudiu Popa2019-02-281-1/+1
| | | | | | with objectmodel Close PyCQA/pylint#2776
* Avoid statement deletion in the _filter_stmts method of the LookupMixin ↵hippo912019-01-231-0/+29
| | | | | | | | | | | | | | class for PartialFunction In the case where the node is a PartialFunction and its name is the same as the current statement's name, avoid the statement deletion. The problem was that a call to a function that has been previously called vit a functools.partial was wrongly inferred. The bug comes from the _filter_stmts method of the LookupMixin class. The deletion of the current statement should not be made in the case where the node is an instance of the PartialFunction class and if the node's name is the same as the statement's name. This change also extracts PartialFunction from brain_functools into astroid.objects so that we remove a circular import problem. Close PyCQA/pylint#2588
* Add a method to the manager to retrieve the builtins moduleClaudiu Popa2019-01-191-2/+2
|
* Add a registry for builtin exception models. Close PyCQA/pylint#1432Claudiu Popa2019-01-171-4/+7
|
* Initial formatting of astroidClaudiu Popa2018-10-021-27/+49
|
* infer_call_result can raise InferenceError so make sure to handle that for ↵Claudiu Popa2018-07-311-2/+4
| | | | | | | | | | | the call sites where it is used infer_call_result started recently to raise InferenceError for objects for which it could not find any returns. Previously it was silently raising a StopIteration, which was especially leaking when calling builtin methods. Since it is after all an inference method, it is expected that it could raise an InferenceError rather than returning nothing. Close PyCQA/pylint#2350
* Update the copyright noticesastroid-2.0Claudiu Popa2018-07-151-2/+5
|
* Fix lint errorsClaudiu Popa2018-05-311-4/+4
|
* Remove reraise() in favour of using raise..fromClaudiu Popa2018-05-311-4/+4
|
* Remove six from a couple of filesClaudiu Popa2018-05-311-2/+2
|
* Add qname method to Super objectsBryce Guinta2018-04-191-0/+3
| | | | | | | | | Super objects in python have a __qualname__ attribute so super nodes should have an equivalent qname method. Prevents an error in upstream pylint Close #533
* Revert "Move FrozenSet to node_classes so it is accessible"Bryce Guinta2018-03-111-0/+15
| | | | This reverts commit 06273cd07d4b3701998df7b2c656d1b029bdee8e.
* Move FrozenSet to node_classes so it is accessibleBryce Guinta2018-03-111-15/+0
| | | | importing astroid.objects causes curcular imports with manager
* Remove pylint errorsDerek Gustafson2016-12-031-0/+3
|
* Even more granular copyrights (thanks to copyrite)Claudiu Popa2016-07-221-2/+3
|
* Keep a consistent copyright notice across the board.Claudiu Popa2016-07-191-0/+2
|
* dict.values, dict.keys and dict.items are properly inferredClaudiu Popa2016-06-041-0/+32
|
* Exceptions have their own object modelClaudiu Popa2016-06-041-0/+11
| | | | | | | | | | | Some of exceptions's attributes, such as .args and .message, can't be inferred correctly since they are descriptors that get transformed into the proper objects at runtime. This can cause issues with the static analysis, since they are inferred as different than what's expected. Now when we're creating instances of exceptions, we're inferring a special object that knows how to transform those runtime attributes into the proper objects via a custom object model. Closes #81
* Introduce a special attributes modelClaudiu Popa2016-06-031-9/+5
| | | | | | | | Through this model, astroid starts knowing special attributes of certain Python objects, such as functions, classes, super objects and so on. This was previously possible before, but now the lookup and the attributes themselves are separated into a new module, objectmodel.py, which describes, in a more comprehensive way, the data model of each object.
* Convert all files to new license headerCeridwen2016-05-161-17/+3
|
* Support accessing properties using super().Claudiu Popa2016-01-141-0/+4
|
* Cleanup pylint's warnings over astroid codebaseClaudiu Popa2015-12-141-2/+2
| | | | | | | | | | Some of the messages were disabled in pylintrc, since they're not very useful for our case. Other parameters, such as the number of arguments / statements / attributes etc were configured so that they won't be too restrictive for our codebase, since making the code to respect them right now requires too much development changes, which is not justified by the end result. Closes issue #284.
* This bookmark adds structured exceptions to astroid.Ceridwen2015-11-021-15/+28
| | | | | | | | | | | | | | | | | | | 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.
* Move bases.NodeNG and bases.Statement in node_classesClaudiu Popa2015-10-111-1/+1
| | | | | | 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.
* Move objects.Slice back into nodes.SliceClaudiu Popa2015-10-031-44/+0
| | | | | | 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.
* Remove trailing whitespace.Claudiu Popa2015-09-261-2/+2
|
* Add a separate Slice object, which is used when inferring the slice builtin callClaudiu Popa2015-09-261-0/+43
| | | | | | | | | | | | | | | | | | | | We do this because of an internal distinction we're making between AST nodes and inference objects. The following distinction might help for understanding better where an AST node is used and where an inference object is used: * if the AST node can be used on its own, e.g. List, Tuple, etc, then the AST can be used in the inference. They have a syntactic display and can be written on its own, e.g. "[]" is a valid list. That's why the inference of their respective builtins (list, tuple, set etc) returns an AST node when inferring. * if the AST node is part of syntax and can't be used on its own. This is the case for slices for instance, e.g "[2:3:4]". In this case, trying to write "2:3:4" on its own will fail. The respective builtin (slice) returns a custom object when inferring and not an AST node per se.
* Add helper function for reraising exceptionsCeridwen2015-09-211-5/+2
|
* Use six.reraise to avoid losing tracebacks for simple casesCeridwen2015-09-211-1/+5
|
* Last merge (hopefully) and all bugs fixed but oneCeridwen2015-08-211-21/+1
|\
| * Understand slices of tuples, lists, strings and instances with support for ↵Claudiu Popa2015-08-211-1/+0
| | | | | | | | | | | | slices. Closes issue #137.
| * Introduce a base class for Set, List and Tuple in order to avoid code ↵Claudiu Popa2015-08-201-13/+1
| | | | | | | | duplication. Closes issue #160.
* | More fixes for bugs introduced during mergeCeridwen2015-08-181-1/+1
| |
* | Fix issues found in code reviewCeridwen2015-08-141-3/+3
| |
* | Fix most obvious errors intorduced by the latest mergeCeridwen2015-08-141-9/+3
| |
* | Merge main into defaultCeridwen2015-08-141-35/+35
|\ \ | |/
| * Big cleanup across the entire projectClaudiu Popa2015-08-121-35/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * 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
* | Node constructors almost finished except for two bugsCeridwen2015-07-081-14/+27
|/
* Implement bool_value correctly for data structures.Claudiu Popa2015-06-161-0/+3
|
* Staticmethods retrieved with super are functions, not bound methods.Claudiu Popa2015-06-151-1/+1
|
* Add a new SuperError exception subclass, SuperArgumentTypeError, which is ↵Claudiu Popa2015-05-291-6/+9
| | | | raised when there's a problem with any argument of the super call (invalid types).
* Fail when calling Super.super_mro if the object-or-type is not the expected ↵Claudiu Popa2015-05-291-1/+4
| | | | type.
* Remove unused import.Claudiu Popa2015-05-281-1/+1
|
* Update the rules for what descriptor is returned from a super(), depending ↵Claudiu Popa2015-05-281-10/+21
| | | | on the accessed object.
* Add a new *inference object* called SuperClaudiu Popa2015-05-281-1/+108
| | | | | | | | | | | | This patch also adds support for understanding super calls. astroid understands the zero-argument form of super, specific to Python 3, where the interpreter fills itself the arguments of the call. Also, we are understanding the 2-argument form of super, both for bounded lookups (super(X, instance)) as well as for unbounded lookups (super(X, Y)), having as well support for validating that the object-or-type is a subtype of the first argument. The unbounded form of super (one argument) is not understood, since it's useless in practice and should be removed from Python's specification. Closes issue #89.