summaryrefslogtreecommitdiff
path: root/astroid/inference.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove the # coding, since PEP3120 the default is UTF8Pierre Sassoulas2021-02-171-1/+0
|
* Add missing copyright annotations for the past releasesClaudiu Popa2020-04-271-2/+5
|
* Cache the inference of FunctionDef to prevent property inference mutating localsClaudiu Popa2020-03-061-1/+23
| | | | | | | | | When inferring a property, we instantiate a new `objects.Property` object, which in turn, because it inherits from `FunctionDef`, sets itself in the locals of the wrapping frame. This means that everytime we infer a property, the locals are mutated with a new instance of the property. Using `context` with `path_wrapper` would not have helped, because we call `inferred()` on functions in multiple places in pylint's codebase.
* Reverse the order of decorators for `infer_subscript`Claudiu Popa2020-03-051-3/+4
| | | | | | | `path_wrapper` needs to come first, followed by `raise_if_nothing_inferred`, otherwise we won't handle `StopIteration` correctly. Close #762
* Don't crash upon invalid contex on attr. inference (#746)Leandro T. C. Melo2020-02-101-0/+2
|
* Use the parent of the node when inferring aug assign nodes instead of the ↵Claudiu Popa2020-01-051-3/+2
| | | | | | | | | | | | | statement In 19b5af02304e3339fdd2a26cfafc337960eeebce we added a check for `AugAssign` nodes when inferring `Assign` values. Unfortunately the `infer_assign` function was also used by `infer_assignname`, which meant that when trying to infer an `AssignName` node, we were inferring its value as the result of the `AugAssign` inference, leading to spurious false positives. Close PyCQA/pylint#2911 Close PyCQA/pylint#3214
* Enable else-if-used extensionNick Drozd2019-12-241-6/+6
|
* Set arguments on inferred properties and property descriptors such as fget()Claudiu Popa2019-12-151-0/+1
|
* Add support for inferring propertiesClaudiu Popa2019-12-041-8/+31
| | | | | These new capabilities will allow inferring both the `property` builtin as well as property attributes such as `.deleter` and `.setter`.
* Pass an inference context to `metaclass()` when inferring an object typeClaudiu Popa2019-10-181-5/+12
| | | | | | | | | This should prevent a bunch of recursion errors happening in pylint. Also refactor the inference of `IfExp` nodes to use separate contexts for each potential branch. Close PyCQA/pylint#3152 Close PyCQA/pylint#3159
* Add inference support to NamedExpr nodesClaudiu Popa2019-06-021-3/+11
|
* Added support for inferring `IfExp` nodes.Claudiu Popa2019-06-011-0/+29
|
* Make sure that Attribute.infer has a protection against StopIterationsClaudiu Popa2019-01-191-3/+5
|
* Remove StopIteration handling which should not leak at all from inferenceClaudiu Popa2019-01-181-9/+1
|
* Move infer_name_module() in pylint and remove it from hereClaudiu Popa2019-01-131-9/+0
|
* Revert path copying in InferenceContext()Claudiu Popa2018-12-301-3/+0
| | | | | | | | While copying the path solves some inference issues, it also leads to horrenduous performance hits on large libraries such as pandas. We still want to have the path copying, but we need a better understanding on why that is needed, as well as a change on how we operate with the inference contexts.
* Multiple "value" or "slice" values on subscript inference.Daniel Martin2018-10-151-46/+43
| | | | Fixes astroid bug #614.
* Replace a nested for loop with a product() callClaudiu Popa2018-10-111-15/+8
|
* Use yield fromClaudiu Popa2018-10-101-2/+1
|
* Remove unneeded commentClaudiu Popa2018-10-101-3/+0
|
* Replace a nested for loop with itertools.productClaudiu Popa2018-10-101-15/+16
|
* Replace checks against None and Uninferable to boolean checksClaudiu Popa2018-10-101-3/+3
| | | | Uninferable acts as None so that should be enough.
* Simplify the creation of extra_context for _infer_callClaudiu Popa2018-10-101-3/+2
|
* Use copy_context where it makes senseClaudiu Popa2018-10-101-6/+5
|
* Initial formatting of astroidClaudiu Popa2018-10-021-94/+143
|
* Pass parameters by keyword name when inferring sequences.Claudiu Popa2018-09-281-1/+2
| | | | Close PyCQA/pylint#2526
* infer_call_result can raise InferenceError so make sure to handle that for ↵Claudiu Popa2018-07-311-1/+0
| | | | | | | | | | | 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
* Cut obsolete "explicit StopIteration" commentsNick Drozd2018-07-301-10/+0
| | | | The explicit StopIterations were themselves were cut in ceeee097.
* Spelling fixesVille Skyttä2018-07-241-2/+2
|
* Fix lint errorBryce Guinta2018-07-241-0/+1
| | | | pylint doesn't understand decorators
* Wrap the inference functions with raise_if_nothing_inferred where we didn't ↵Claudiu Popa2018-07-241-1/+16
| | | | | | | have any guards against them This is especially important in a Python 3.7 worlds where we need to handle StopIteration that can be triggered by next() over empty generators.
* Rename method for making it clearerClaudiu Popa2018-07-241-15/+15
|
* Update the copyright noticesastroid-2.0Claudiu Popa2018-07-151-2/+14
|
* Fix inference for nested callsBryce Guinta2018-07-051-3/+3
| | | | | | | | | Add context_lookup to the context class as extra_context. Deliver the correct context with the correct boundnode for function argument nodes. Close #177
* Refactor assinging boundnode to contextBryce Guinta2018-07-041-7/+4
| | | | | Code in multiple places had the same pattern for infering call results.
* Make sure that context_lookup is always definedClaudiu Popa2018-06-131-1/+6
|
* Remove useless TODOs that are either issues in the issue tracker or things ↵Claudiu Popa2018-06-121-7/+2
| | | | which we'll never get to fix/change
* Convert to yield fromNick Drozd2018-06-081-17/+9
| | | | | | | I tried this to see if it would improve performance. It didn't, but it does look nicer, so we might as well keep it. See also 5fd5aa81483e709cb5c464c7d4bb37c8c39f2afa
* Don't propagate Uninferable objects when inferring BinOpsClaudiu Popa2018-06-051-0/+2
| | | | Close PyCQA/pylint#2059
* Remove reraise() in favour of using raise..fromClaudiu Popa2018-05-311-14/+27
|
* Fix lint errorsAshley Whetter2018-05-051-6/+6
|
* Fix StopIteration raising for python3.7 (#534)HoverHell2018-04-241-8/+14
| | | | | | Because we don't support Python 2 any longer in the master branch, we can return values from generators to signal that we want to throw a StopIteration, without actually raising the StopIteration itself.
* Set context boundnode for binary operation to correct inferenceBryce Guinta2018-03-301-0/+2
|
* Add context_lookup to infer_call_result for function argumentsBryce Guinta2018-03-301-1/+20
| | | | | | | | This allows inference of function arguments to be different than the inference of the function body Currently this is only used for object.__new__(cls) calls but can be expanded later
* Fix duplicate values in inferred dictionary node from dictionary unpackingBryce Guinta2018-03-021-2/+26
|
* Fix augassign recursion errorBryce Guinta2018-02-181-5/+0
| | | | | | | | | | | | | | | The augmented assign rhs context path was deleted most likely due to a recently fixed inference bug where InferenceContext path attributes were shared between objects. Recursive functions on the right hand side of the augmented assign would forget that they were already called, causing an eventual RecursionError in astroid inference Now that the InferenceContext clone() method properly copies the inference path between Contexts, it's fine to remove this hack. Fixes #437, Fixes #447, Fixes #313, Fixes PyCQA/pylint#1642, Fixes PyCQA/pylint#1805, Fixes PyCQA/pylint#1854, Fixes PyCQA/pylint#1452
* Fix lint warningsClaudiu Popa2017-10-121-0/+1
|
* Skip Uninferable inferred objects when inferring a DictClaudiu Popa2017-08-121-1/+1
| | | | Close PyCQA/pylint#1619
* Catch _NonDeducibleTypeHierarchy in inference._infer_augassign (#443)Michał Masłowski2017-07-081-4/+2
| | | | Similarly to _infer_binop, we have to handle exceptions raised by helpers.is_subtype and helpers.is_supertype in _infer_augassign.
* TypoClaudiu Popa2017-03-121-1/+1
|