summaryrefslogtreecommitdiff
path: root/tests/unittest_inference.py
Commit message (Collapse)AuthorAgeFilesLines
* Properly construct the arguments of infered property descriptors (#796)Claudiu Popa2020-05-281-0/+17
| | | Close PyCQA/pylint#3648
* Protect against ``infer_call_result`` failing with `InferenceError` in ↵Claudiu Popa2020-05-011-0/+28
| | | | | | | | `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/+7
|
* ``BoundMethod.implicit_parameters`` returns a proper value for ``__new__``Claudiu Popa2020-03-261-0/+21
| | | | Close PyCQA/pylint#2335
* Allow `FunctionDef.getattr` to look into both instance attrs and special ↵Claudiu Popa2020-03-261-0/+16
| | | | | | | | | | attributes Modifying an attribute of a function with an augmented assignment resulted in `FunctionDef.getattr` to prioritize the instance attributes fetching. This means that only the augmented assignment modification would have been visible. Close PyCQA/pylint#1078
* Remove Python 2 specific testsClaudiu Popa2020-03-101-24/+0
|
* Use pytest.xfail instead of unittest.expectedFailure to have a common ↵Claudiu Popa2020-03-101-5/+5
| | | | decorator across the codebase
* Prevent a recursion error for self reference variables and `type()` calls.Claudiu Popa2020-03-101-0/+20
| | | | | | | | | The recursion error was caused by inferring the bases of the generated `B` class multiple times. The solution uses the new `EvaluatedObject` class to stop the inference by inferring the base classes in the `type` inference function. Close #199
* Add a new EvaluatedObject containerClaudiu Popa2020-03-101-4/+19
| | | | | | | | | This container is used to store values that have already been evaluated. For instance, 79d5a3a783cf0b5a729e4e467508e955a0cca55f added support for inferring `tuple()` call arguments, but as a result, the `elts` of a `Tuple` can be objects not *references*. As a result, `Tuple.elts` can contain class objects rather than references (names) to class object. The `EvaluatedObject` helps with that, as we still have to call `.infer()` (albeit a no-op) to grab the inferred value of an element.
* Prevent a recursion error to happen when inferring the declared metaclass of ↵Claudiu Popa2020-03-071-0/+9
| | | | | | a class Close #749
* Do not infer the first argument of a staticmethod in a metaclass as the ↵Claudiu Popa2020-03-071-0/+12
| | | | | | class itself Close PyCQA/pylint#3032
* Raise ``AttributeInferenceError`` when ``getattr()`` receives an empty nameClaudiu Popa2020-03-061-0/+14
| | | | | | | | | | | If `Module.getattr` received an empty string (as a result of inference for example), `astroid` would have returned the same Module again, which leads to false positives in pylint, since the expected output was of a different type. Rather than allowing empty names to pass through `getattr()`, we simply raise an error earlier. Close PyCQA/pylint#2991
* Cache the inference of FunctionDef to prevent property inference mutating localsClaudiu Popa2020-03-061-0/+22
| | | | | | | | | 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.
* Add support for converting Property objects to stringsClaudiu Popa2020-03-061-0/+23
|
* Prevent a recursion error when inferring self-referential variables without ↵Claudiu Popa2020-03-051-0/+17
| | | | | | definition Close PyCQA/pylint#1285
* Reverse the order of decorators for `infer_subscript`Claudiu Popa2020-03-051-0/+21
| | | | | | | `path_wrapper` needs to come first, followed by `raise_if_nothing_inferred`, otherwise we won't handle `StopIteration` correctly. Close #762
* Verify the existence of datetime and date in ancestors instead of objectClaudiu Popa2020-03-031-1/+3
| | | | | `object` cannot be inferred as an ancestor of datetime.date on PyPy, due to a base class that is not inferrable.
* Better inference of class and static methods decorated with custom methodsClaudiu Popa2020-03-031-0/+78
| | | | Close PyCQA/pylint#3209
* Pass a context argument to ``astroid.Arguments`` to prevent recursion errorsClaudiu Popa2020-03-021-0/+11
| | | | Close PyCQA/pylint#3414
* Infer qualified ``classmethod`` as a classmethod. (#759)Claudiu Popa2020-02-271-0/+21
| | | Close PyCQA/pylint#3417
* Use the parent of the node when inferring aug assign nodes instead of the ↵Claudiu Popa2020-01-051-0/+18
| | | | | | | | | | | | | 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
* Make use of cache while transform builtin containersStanislav Levin2019-12-231-0/+14
| | | | | | | | | | | | | | | As of now, the transformation of builtin containers which members, in turn, are containers relies on `safe_infer` helper. `safe_infer` tries to infer the node to get its values. Doing this without a cache containing a previously inferred nodes lead to infinite recursion, for example, on resolving a class attribute. Note: this doesn't help to infer a class attribute by itself is such a case, but prevents crash. Closes: https://github.com/PyCQA/pylint/issues/3245 Signed-off-by: Stanislav Levin <slev@altlinux.org>
* Handle StopIteration error in infer_int.David Liu2019-12-091-0/+18
| | | | | | | | | | | This fixes https://github.com/PyCQA/pylint/issues/3274. Prior to Python 3.7, StopIteration errors bubbled up through generators, so this wasn't an issue for astroid because the StopIteration error was handled later. Now StopIteration errors are converted to RuntimeErrors [1], so the same error handling doesn't work. [1]: https://www.python.org/dev/peps/pep-0479/
* Add support for inferring propertiesClaudiu Popa2019-12-041-0/+62
| | | | | These new capabilities will allow inferring both the `property` builtin as well as property attributes such as `.deleter` and `.setter`.
* Scope the inference to the current bound node when inferring instances of ↵Claudiu Popa2019-11-251-0/+52
| | | | | | | | | | | | | classes When inferring instances of classes from arguments, such as ``self`` in a bound method, we could use as a hint the context's ``boundnode``, which indicates the instance from which the inference originated. As an example, a subclass that uses a parent's method which returns ``self``, will override the ``self`` to point to it instead of pointing to the parent class. Close PyCQA/pylint#3157
* Allow attribute assignment for exception instancesClaudiu Popa2019-11-171-0/+22
|
* Add support for inferring exception instances in all contextsClaudiu Popa2019-11-171-7/+17
| | | | | | | | | | | We were able to infer exception instances as ``ExceptionInstance`` only for a handful of cases, but not all. ``ExceptionInstance`` has support for better inference of `.args` and other exception related attributes that normal instances do not have. This additional support should remove certain false positives related to ``.args`` and other exception attributes in ``pylint``. Close PyCQA/pylint#2333
* Infer args unpacking of ``self``Claudiu Popa2019-11-141-0/+19
| | | | | | | | | | Certain stdlib modules use ``*args`` to encapsulate the ``self`` parameter, which results in uninferable instances given we rely on the presence of the ``self`` argument to figure out the instance where we should be setting attributes. Close PyCQA/pylint#3216
* Allow inferring positional only arguments on Python 3.8Claudiu Popa2019-11-141-0/+26
|
* Moved tests out of package directory (#704)Ashley Whetter2019-10-151-0/+5297