summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Fix a crash caused by a lookup of a monkey-patched method (#803)2.4Claudiu Popa2020-06-161-0/+19
| | | Close PyCQA/pylint#3686
* Properly construct the arguments of infered property descriptors (#796)Claudiu Popa2020-05-281-0/+17
| | | Close PyCQA/pylint#3648
* `FunctionDef.is_generator` properly handles `yield` nodes in `While` testsClaudiu Popa2020-05-121-0/+12
| | | | Close PyCQA/pylint#3519
* 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
* Do not crash with SyntaxError when parsing namedtuples with invalid labelClaudiu Popa2020-05-011-0/+12
| | | | Close PyCQA/pylint#3549
* Add missing copyright annotations for the past releasesClaudiu Popa2020-04-2726-34/+86
|
* Add posonlyargs_annotations to Arguments.as_string()Claudiu Popa2020-03-281-0/+6
|
* ``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
* Allow slots added dynamically to a class to still be inferredClaudiu Popa2020-03-131-0/+15
| | | | | | | | | | | | | | | | In 2aa27e9aed6ffcba4a61655e291e852ecd001549 `ClassDef.igetattr` was modified to only grab the first item from the result of `getattr`, in order to avoid looking up attributes in the ancestors path when inferring attributes for a given class. This had the side effect that we'd omit attribute definitions happening in the same scope, such as augmented assignments, which in turn might have affected other capabilities, such as slots inference. This commit changes the approach a bit and keeps all attributes as long as all of them are from the same class (be it current or an ancestor) Close PyCQA/pylint#2334
* Add a regression test for inferring self in lambdaClaudiu Popa2020-03-121-0/+12
| | | | Close #425
* Kill `extrapath` from various `modutils` functions as it was not usedClaudiu Popa2020-03-111-8/+0
|
* Add a new ast_from_string method to AstroidManagerAnubhav2020-03-111-0/+11
| | | Close #725
* Remove Python 2 specific testsClaudiu Popa2020-03-106-354/+0
|
* Use pytest.xfail instead of unittest.expectedFailure to have a common ↵Claudiu Popa2020-03-102-7/+7
| | | | decorator across the codebase
* Change test that expected as_string() to return a particular number of newlinesClaudiu Popa2020-03-101-7/+6
|
* Infer the __len__ result of a subclass of an integerClaudiu Popa2020-03-101-4/+7
| | | | | Rather than failing the inference altogether, we can infer the default int value for subclasses of ints.
* 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-074-0/+29
| | | | | | 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
* Disable test on PyPy since we cannot get 7.2 easily without manually ↵Claudiu Popa2020-03-031-1/+7
| | | | installing it
* 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
* numpy.astype now returns a ndarray objecthippo912020-02-101-0/+28
| | | | | | | This fixes PyCQA/pylint#3332. The bug was due to the fact that datetime64 class inherited from generic one and in this last class the astype method was returning uninferable. Now it returns ndarray object. This fix should be generalized to all other methods of the generic class as the numpy doc specifies that the generic object API should be the same as the ndarray one.
* Skip non ``Assign`` and ``AnnAssign`` nodes from enum reinterpretationClaudiu Popa2020-02-101-0/+15
| | | | Closes PyCQA/pylint#3365
* Make imag and real attributes numpy.ndarrayhippo912020-02-101-0/+31
| | | Close PyCQA/pylint#3322
* Can access positional only and keyword only argument type commentsAshley Whetter2020-01-111-0/+41
|
* 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
* Add the float_power function in the brain and in its associated testhippo912019-12-301-0/+6
| | | | | | | | The bug PyCQA/pylint#3319 was caused due to a missing function, named float_power inside the brain_numpy_core_umath module. This brain is used to infer all the numpy's ufunc functions. The problem is that in the website documentation of numpy, in the section that list all those functions, there is not entry dealing with the float_power function. Also adds 5 missing functions detected by @texadactyl Closes PyCQA/pylint#3319
* Add missing methods of the numpy.core.multiarray module.hippo912019-12-241-7/+118
| | | Closes PyCQA/pylint#3208
* 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>
* Allow inferring attributes of `HTTPStatus` callableClaudiu Popa2019-12-161-0/+9
| | | | Close PyCQA/pylint#3296
* ``nodes.Const.itered`` returns a list of ``Const`` nodes, not stringsClaudiu Popa2019-12-151-0/+9
| | | | | | | Because ``Const.itered`` was not returning proper nodes, pylint was failing when trying to infer objects created from those nodes. Close PyCQA/pylint#3306
* 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/
* Reformatting according to blackhippo912019-12-091-15/+39
|
* Reactivates tests for functions whose result is inferred as an ndarray and ↵hippo912019-12-091-10/+10
| | | | uninferable.
* Ufunc objects are no more functions but instances a fake Ufunc classhippo912019-12-091-1/+1
|
* Adds unittest for ufunc objects returning pair of ndarrayhippo912019-12-091-2/+33
|
* Takes into account the fact thathippo912019-12-091-34/+14
| | | | | ufunc functions are now instances of FakeUfunc class and that the call to these functions implies the use of __call__ protocol.
* geterrobj et seterrobj are not ufunc objectshippo912019-12-091-8/+4
|
* Add support for inferring propertiesClaudiu Popa2019-12-043-3/+65
| | | | | These new capabilities will allow inferring both the `property` builtin as well as property attributes such as `.deleter` and `.setter`.
* Disable test on Python 3.8+ where the builtin ast does not have a specific errorClaudiu Popa2019-11-261-0/+8
|