summaryrefslogtreecommitdiff
path: root/astroid/inference.py
Commit message (Collapse)AuthorAgeFilesLines
* AstroidBuildingException is now AstroidBuildingError.Claudiu Popa2015-12-061-2/+2
| | | | The first name will exist until astroid 2.0.
* Add two new exceptions, AstroidImportError and AstroidSyntaxError.Claudiu Popa2015-12-061-6/+18
| | | | | | | | 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.
* Merge upstream changesCeridwen2015-11-061-26/+53
|\
| * Rename Uninferable and instatiate_classCeridwen2015-11-061-38/+38
| |
| * Add structured exceptions to decorators and remaining functions.Ceridwen2015-11-061-7/+21
| | | | | | | | | | | | | | | | | | | | * Use explicit StopIteration to pass information from generators to raise_if_nothing_inferred and path_wrapper, rather than return or implicit termination by reaching the end of the code block. * Remove remove_nodes in favor of handling the cases in local_attr, istance_attr, and getattr, to avoid the need for complicated information passing when needing to raise an exception.
| * This bookmark adds structured exceptions to astroid.Ceridwen2015-11-021-26/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Rename Uninferable and instantiate_class, fix broken tests, improveCeridwen2015-11-061-38/+38
|/ | | | | | | | | | | 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.
* Merged in dmand/astroid/binop-inference-fix (pull request #92)Claudiu Popa2015-10-231-7/+7
|\ | | | | | | Fix binary operator inference issue from pylint's #646
| * Fix binary operation inference crash by using cloned contextsbinop-inference-fixDmitry Pribysh2015-10-211-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Idea is that we shouldn't use the same context to infer left-hand side and right-hand side of the binary operation because inferring lhs may leave some metadata in context.path that is irrelevant (and can even break inference) to inference of rhs. So we make two clones of the original context and use them to infer left-hand side and right-hand side independently. And then we use the original context to infer the result of the operation applied to inferred values. This patch fixes pylint's issue #646 and may be also related to other similar astroid issues (#198, #199).
* | Add support for indexing containers with instances which provides an ↵Claudiu Popa2015-10-221-0/+4
| | | | | | | | | | | | | | | | __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.
* | Create a call context when inferring unary operands on instances.Claudiu Popa2015-10-221-0/+3
|/
* Remove doctype and future imports which aren't useful.Claudiu Popa2015-10-111-2/+0
|
* Move decorators from bases to decorators module.Claudiu Popa2015-10-111-19/+20
|
* Don't wrap instance's arguments into a Const, instead let the original index ↵Claudiu Popa2015-10-031-19/+16
| | | | | | | | object to be used. This prevents a crash when the original index object is a slice object, which was wrapped inadvertendly in a Const node, leading to a crash later on if the said object was inferred. Closes issue #200.
* Fix a crash which occurred when inferring unary operands which yielded ↵Claudiu Popa2015-10-031-0/+2
| | | | objects which weren't callable.
* Fix pylint errors.Claudiu Popa2015-09-261-2/+0
|
* Merged in ceridwenv/astroid (pull request #88)Claudiu Popa2015-09-261-4/+4
|\ | | | | | | Use six.reraise to avoid losing tracebacks for simple cases
| * Add helper function for reraising exceptionsCeridwen2015-09-211-13/+4
| |
| * Use six.reraise to avoid losing tracebacks for simple casesCeridwen2015-09-211-4/+13
| |
* | Fix a crash when inferring subscripts which returned the same object all the ↵Claudiu Popa2015-09-251-3/+6
|/ | | | time.
* Improve the understanding of argumentsClaudiu Popa2015-09-091-0/+1
| | | | | | | | This changeset introduces a better way to understand arguments passed into call sites. The original logic was moved from astroid.context.CallContext, which become only a container for arguments and keyword arguments, to astroid.arguments.ArgumentInferator, a new class for understanding arguments.
* First pass of the Python 3.5 support.Claudiu Popa2015-09-071-3/+1
|
* Disable the no-value-for-parameter message for now, since it's a false ↵Claudiu Popa2015-08-261-0/+2
| | | | positive that needs to be fixed later on in Pylint.
* Last merge (hopefully) and all bugs fixed but oneCeridwen2015-08-211-33/+37
|\
| * Add tests for aliasesCeridwen2015-08-211-2/+4
| |
| * More fixes for bugs introduced during mergeCeridwen2015-08-181-13/+15
| |
| * Fix most obvious errors intorduced by the latest mergeCeridwen2015-08-141-4/+4
| |
| * Merge main into defaultCeridwen2015-08-141-210/+129
| |\
| * | Fix bugs introduced by merge and formattingCeridwen2015-07-111-1/+1
| | |
| * | Merged changes from logilab/astroidCeridwen2015-07-101-28/+28
| |\ \
| | * | Node constructors almost finished except for two bugsCeridwen2015-07-081-28/+28
| | | |
* | | | Understand slices of tuples, lists, strings and instances with support for ↵Claudiu Popa2015-08-211-17/+71
| |_|/ |/| | | | | | | | | | | | | | slices. Closes issue #137.
* | | Big cleanup across the entire projectClaudiu Popa2015-08-121-70/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Remove unused import.Claudiu Popa2015-08-121-1/+1
| | |
* | | Move InferenceContext and CallContext into astroid.contextClaudiu Popa2015-08-121-101/+16
| | | | | | | | | | | | | | | | | | | | | 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-40/+41
| | | | | | | | | | | | | | | | | | | | | 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*.
* | | Remove trailing whitespace.Claudiu Popa2015-08-081-1/+1
| | |
* | | Add CallFunc.keywords, instead of putting together args and kwargs in ↵Claudiu Popa2015-08-081-22/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Move the choosing of the predicate at the beginning of the function.Claudiu Popa2015-08-041-6/+5
|/ /
* | Infer the unary method retrieved from classes.Claudiu Popa2015-07-031-2/+3
|/
* Add support for inferring methods masquerading as others for the binop ↵Claudiu Popa2015-07-021-1/+2
| | | | protocols.
* Remove trailing whitespace.Claudiu Popa2015-07-011-1/+1
|
* Add support for inferring subscript on instances, which will use ↵Claudiu Popa2015-07-011-2/+29
| | | | __getitem__. Closes issue #124.
* Add support for retrieving TypeErrors for binary arithmetic operations and ↵Claudiu Popa2015-06-281-14/+36
| | | | | | | | | 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.
* Move UnaryOp code to be closer to BinaryOp.Claudiu Popa2015-06-281-56/+57
|
* Improve the inference of binary arithmetic operations (normal and augmented)Claudiu Popa2015-06-271-42/+235
| | | | | | 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.
* Fix pylint warnings.Claudiu Popa2015-06-161-4/+2
|
* Add inference support for boolean operations (`and` and `not`).Claudiu Popa2015-06-161-5/+59
|
* Add a new method to the AST nodes, 'bool_value'.Claudiu Popa2015-06-141-2/+8
| | | | | | | | | | 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.
* Make the first steps towards detecting type errors for unary and binary ↵Claudiu Popa2015-06-111-23/+36
| | | | | | | | | | | | 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.