diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2020-03-04 18:15:18 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2020-03-04 19:00:35 +0100 |
commit | 01b5b572149f19550d4fdec3fd7d1e40aee9b624 (patch) | |
tree | 19398460c2a2ba5b697b36d13fdbdab786565d98 /astroid/inference.py | |
parent | 8999464dec374946a02b807e9b0e13052bc9cd1f (diff) | |
download | astroid-git-01b5b572149f19550d4fdec3fd7d1e40aee9b624.tar.gz |
Transform boto3.ServiceRequest to look like dynamic class
`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
Diffstat (limited to 'astroid/inference.py')
0 files changed, 0 insertions, 0 deletions