-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instance of '' has no 'Topic' member (no-member) for boto3.resource('sns').Topic #3134
Comments
Apologies, I had the pages for both pylint and astroid open, and thought I was raising an issue on the pylint project. Is it possible to move it? |
Can confirm the issue, thanks. |
Thanks for the great tools! You most likely don't require any assistance in debugging, but I ran into this issue as well and dug around for a while. It seems to me that this issue was introduced as a side-effect of #2841. |
TIP: we did some digging and (we suspect) this is an issue with objects that dynamically construct their member methods. https://github.com/boto/botocore/blob/develop/botocore/client.py#L330 |
Another example (for reproduction) could be: import boto3
dynamodb = boto3.resource('dynamodb', region_name='us-west-2')
device_table = dynamodb.create_table( ... <stuff> ...) Pylint complains about lines that do that now in the latest version
|
What is the suggested workaround at this time? Apart from littering the code base with EDIT: for now in
, and whatever other class paths are affected |
Hi @PCManticore , is there any update on this? thanks. |
@mcallaghan-bsm @kirintwn No updates yet. There are ~500 issues on this tracker and we're volunteers on this project, so it could take us a while to get to it. Unfortunately I don't have many hours available per week to work on this project, and I do what I can to make its maintenance manageable. What I'm saying is if this is an important problem for you, investigating why it happens or working on a patch or anything that can help us speed it up would be tremendous. |
We can confirm that the bug is in astroids as upgrading from astroids 2.2.5 to 2.3.0 triggers the issue with pylint 2.3.1. We cloned the astroid repo, did
The regression was introduced by this change for #2841, as mentioned above: We updated From:
To:
Of course we have no familiarity with this codebase so we might have introduced an other side effect. @PCManticore I hope this will help you get a fix. Since this is a regression it should probably be prioritized over other open issues. |
Add workaround for pylint-dev/pylint#3134
We are upgrading our systems to Python 3.8 and unfortunately the older version of pylint is incompatible and we worked around the issue by applying this patch to
Everything seems to work well with pylint 2.4.4, astroid 2.3.3, the patch and Python 3.8.1. I'll prepare a pull request on the Astroid side. |
This fixes the regression documented in pylint-dev/pylint#3134 and introduced in pylint-dev/pylint#2841.
`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 pylint-dev/pylint#3134
I had some time to investigate this. With the aforementioned "revert" PR,
Without the PR, with the code from Unfortunately, accessing Because Even Now a solution would be to revert the aforementioned commit, but I disagree that's needed. It simply removes a functionality just to appease the meta-programming of this library. Another solution would be to use Another solution is pylint-dev/astroid#763 which makes |
`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 pylint-dev/pylint#3134
Since upgrading to the latest pylint/astroid versions, we've started getting this error reported.
We don't get the error when we use
Steps to reproduce
pylint_test.py
:pylint pylint_test.py
Current behavior
This error is reported:
pytlint_test.py:3:0: E1101: Instance of '' has no 'Topic' member (no-member)
Expected behavior
No error is reported
python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
output2.3.0
also,
pylint==2.4.1
The text was updated successfully, but these errors were encountered: