| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| | |
| | |
| | |
| | | |
Close PyCQA/pylint#3549
|
| | |
| | |
| | | |
Closes #779
|
| | |
| | |
| | |
| | | |
Close #774
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
method
|
| | |
| | |
| | |
| | | |
Close PyCQA/pylint#3509
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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>
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
Close PyCQA/pylint#2335
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | | |
Close #425
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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`.
|
| | | |
|
| | |
| | |
| | | |
Close #725
|
| | | |
|
| | |
| | |
| | |
| | | |
decorator across the codebase
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
Rather than failing the inference altogether, we can infer the default
int value for subclasses of ints.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | |
| | |
| | | |
a class
Close #749
|
| | |
| | |
| | |
| | |
| | |
| | | |
class itself
Close PyCQA/pylint#3032
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | | |
before setting locals
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | | |
definition
Close PyCQA/pylint#1285
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`path_wrapper` needs to come first, followed by `raise_if_nothing_inferred`,
otherwise we won't handle `StopIteration` correctly.
Close #762
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`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
|
| | |
| | |
| | |
| | | |
installing it
|
| | |
| | |
| | |
| | |
| | | |
`object` cannot be inferred as an ancestor of datetime.date on PyPy, due to
a base class that is not inferrable.
|
| | | |
|
| | |
| | |
| | |
| | | |
Close PyCQA/pylint#3209
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
Close PyCQA/pylint#3414
|
| | |
| | |
| | | |
Close PyCQA/pylint#3417
|
| | |
| | |
| | | |
Closes PyCQA/astroid#755
|