summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Do not crash with SyntaxError when parsing namedtuples with invalid labelClaudiu Popa2020-05-013-0/+18
| | | | | | | | | | | | Close PyCQA/pylint#3549
* | | Changed `python_requires` to use ">=" syntax (#780)Colin Kennedy2020-05-012-1/+5
| | | | | | | | | Closes #779
* | | Exclude tests from getting installed from source distributionClaudiu Popa2020-05-012-1/+3
| | | | | | | | | | | | Close #774
* | | Restructure the AST parsing heuristic to always pick the same moduleClaudiu Popa2020-04-294-103/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a file contained a misplaced type annotation, we were retrying the parsing without type comments support. That second parsing was using the builtin ast module, but the rest of the tree utilities (the builder and rebuilder) were not aware of the new parsing module that was used to build the AST nodes a second time. This commit moves the logic of picking the parsing module and the corresponding AST node mapping in a single place, which can be used by both the builder and the rebuilder. Close PyCQA/pylint#3540 Close #773
* | | Handle the case where the raw builder fails to retrieve the ``__all__`` ↵Claudiu Popa2020-04-282-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | attribute PyQT does something special with their objects and retrieving some of them (such as `__all__`) at runtime results in a RuntimeError. This patch simply swallows all the exceptions that accessing `__all__` might raise. Close #772
* | | master is now 2.5.0Claudiu Popa2020-04-282-1/+6
| | |
* | | Prepare 2.4.0 release of astroidastroid-2.4.0Claudiu Popa2020-04-272-1/+2
| | |
* | | Add missing copyright annotations for the past releasesClaudiu Popa2020-04-2779-98/+220
| | |
* | | Transform read_module() into a lambda to prevent it being marked as a bound ↵Claudiu Popa2020-04-271-1/+1
| | | | | | | | | | | | method
* | | Export `six.moves.reload_module` from `importlib` not `imp`Claudiu Popa2020-04-271-1/+2
| | | | | | | | | | | | Close PyCQA/pylint#3509
* | | Fix formatting errorClaudiu Popa2020-04-031-1/+1
| | |
* | | Inspect compiled CFFI extension membersRobin Jarry2020-04-032-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To use a CFFI extension, its "lib" symbol gives access to the exported C symbols and its "ffi" symbol gives access to low-level utilities. An import such as the following is required: from _compiled_extension_module import ffi from _compiled_extension_module import lib Then in the code, these objects are used to access the C symbols: pp = ffi.cast('struct mystruct *', p) lib.exported_c_function(pp) Even if "_compiled_extension_module" is added to AstroidManager.extension_package_whitelist, the "ffi" and "lib" objects are not analyzed properly since they do not fall into any of the supported categories of objects. A dummy "builtin.module" node is inserted in their place preventing tools like pylint to properly detect object membership. Thus producing invalid errors: Instance of 'module' has no 'cast' member [no-member] Instance of 'module' has no 'exported_c_function' member [no-member] Both these objects define __all__ attributes which lists their exported symbols. The presence of __all__ means that dir(member) will work and that object_build may be called recursively on that member. Insert a Module node to represent these objects and add their members to the built AST. Link: https://cffi.readthedocs.io/en/latest/overview.html#main-mode-of-usage Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
* | | Add posonlyargs_annotations to Arguments.get_children()Claudiu Popa2020-03-281-0/+6
| | |
* | | Add posonlyargs_annotations to Arguments.as_string()Claudiu Popa2020-03-282-1/+13
| | |
* | | ``BoundMethod.implicit_parameters`` returns a proper value for ``__new__``Claudiu Popa2020-03-263-0/+28
| | | | | | | | | | | | Close PyCQA/pylint#2335
* | | Allow `FunctionDef.getattr` to look into both instance attrs and special ↵Claudiu Popa2020-03-263-2/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-133-3/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge TreeRebuilder3 into TreeRebuilderClaudiu Popa2020-03-121-165/+111
| | | | | | | | | | | | | | | | | | | | | These were separated to allow us to add support for parsing Python 2 files as well as Python 3. Unfortunately that is no longer in our plans and since the code was already broken (e.g. the Raise node was receiving unexpected arguments), it's better to rip the bandaid and merge the two classes together.
* | | Add a regression test for inferring self in lambdaClaudiu Popa2020-03-121-0/+12
| | | | | | | | | | | | Close #425
* | | Add an optional `path` parameter to `modpath_from_file`Claudiu Popa2020-03-111-16/+21
| | | | | | | | | | | | | | | | | | | | | Because we'll no longer have the current working directory, nor the module's directory in `sys.path`, we need to be able to pass additional paths to be checked against when trying to load a module. Most of the functions in this module already accepted a `path` parameter, except `modpath_from_file`.
* | | Kill `extrapath` from various `modutils` functions as it was not usedClaudiu Popa2020-03-112-33/+8
| | |
* | | Add a new ast_from_string method to AstroidManagerAnubhav2020-03-113-0/+22
| | | | | | | | | 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-102-6/+18
| | | | | | | | | | | | | | | Rather than failing the inference altogether, we can infer the default int value for subclasses of ints.
* | | Call super() for EvaluatedObjectClaudiu Popa2020-03-101-3/+5
| | |
* | | Prevent a recursion error for self reference variables and `type()` calls.Claudiu Popa2020-03-103-1/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-105-7/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-076-1/+35
| | | | | | | | | | | | | | | | | | a class Close #749
* | | Do not infer the first argument of a staticmethod in a metaclass as the ↵Claudiu Popa2020-03-073-2/+23
| | | | | | | | | | | | | | | | | | class itself Close PyCQA/pylint#3032
* | | Raise ``AttributeInferenceError`` when ``getattr()`` receives an empty nameClaudiu Popa2020-03-063-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-062-1/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 super call with setting the function to allow string representation ↵Claudiu Popa2020-03-061-1/+1
| | | | | | | | | | | | before setting locals
* | | Merge AsStringVisitor3 into AsStringVisitor since we no longer support Python 2Claudiu Popa2020-03-061-110/+71
| | |
* | | Add support for converting Property objects to stringsClaudiu Popa2020-03-062-0/+26
| | |
* | | Prevent a recursion error when inferring self-referential variables without ↵Claudiu Popa2020-03-053-1/+22
| | | | | | | | | | | | | | | | | | definition Close PyCQA/pylint#1285
* | | ``NodeNG.bool_value()`` gained an optional ``context`` parameterClaudiu Popa2020-03-055-19/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | We need to pass an inference context downstream when inferring the boolean value of a node in order to prevent recursion errors and double inference. This fix prevents a recursion error with dask library. Close PyCQA/pylint#2985
* | | Reverse the order of decorators for `infer_subscript`Claudiu Popa2020-03-053-3/+32
| | | | | | | | | | | | | | | | | | | | | `path_wrapper` needs to come first, followed by `raise_if_nothing_inferred`, otherwise we won't handle `StopIteration` correctly. Close #762
* | | Transform boto3.ServiceRequest to look like dynamic classClaudiu Popa2020-03-041-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `boto3.resource` creates resources dynamically via a resource factory. Unfortunately that completely breaks static analysis leading to spurious false positives since pylint cannot determine sanely that attributes exist or not. Here's an example of accessing the Topic class out of the `sns` resource. As you can see, the class is created dynamically rather than existing in the codebase itself: ``` In [2]: boto3.resource Out[2]: <function boto3.resource(*args, **kwargs)> In [3]: boto3.resource('sns') Out[3]: sns.ServiceResource() In [4]: boto3.resource('sns').Topic Out[4]: <bound method ResourceFactory._create_class_partial.<locals>.create_resource of sns.ServiceResource()> ``` This patch adds a fake `__getattr__` method to `ServiceRequest`. This will prevent `pylint` from emitting `no-member` at all for `ServiceRequest` instances, but that is a good solution for now until we can load typeshed-like annotation packages. Close PyCQA/pylint#3134
* | | 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.
* | | Try to update pypy to 3.6.1Claudiu Popa2020-03-031-1/+1
| | |
* | | Better inference of class and static methods decorated with custom methodsClaudiu Popa2020-03-033-0/+97
| | | | | | | | | | | | Close PyCQA/pylint#3209
* | | Wrap coverage in quotesClaudiu Popa2020-03-021-1/+1
| | |
* | | Force coverage<5 in travis just like in toxClaudiu Popa2020-03-021-1/+1
| | |
* | | Pass a context to Arguments.call_site() callsClaudiu Popa2020-03-024-9/+9
| | |
* | | Pass a context argument to ``astroid.Arguments`` to prevent recursion errorsClaudiu Popa2020-03-024-14/+44
| | | | | | | | | | | | Close PyCQA/pylint#3414
* | | Infer qualified ``classmethod`` as a classmethod. (#759)Claudiu Popa2020-02-273-5/+40
| | | | | | | | | Close PyCQA/pylint#3417
* | | Relax upper bound on `wrapt` (#756)Michael2020-02-273-2/+6
| | | | | | | | | Closes PyCQA/astroid#755