Is there any way to make linting of boto3 client code more effective? The problem is that methods, classes etc. all seem to be dynamically injected into the boto3 client objects and hence pylint cannot assist the programmer.
Sample code:
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('employee')
Example of pylint output:
{
"resource": "xyz.py",
"owner": "python",
"code": "no-member",
"severity": 8,
"message": "Instance of '' has no 'Table' member",
"source": "pylint",
"startLineNumber": 3,
"startColumn": 9,
"endLineNumber": 3,
"endColumn": 9
}
It would be good not to have to suppress type checking in pylintrc, as follows:
[TYPECHECK]
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=.*dynamodb.*
Thank you for your post. Pylint is not able to handle dynamically generated class so you are getting this error "Instance of '' has no 'Table' member" and i don't think we can do much on the boto3 side to handle this as most of the boto3 classes are generated dynamically.
In this case you can disable pylint for the specific part of code something like this :
import boto3
res = boto3.resource('dynamodb')
table = res.Table('Music')# pylint: disable=no-member
class A:
def __init__(self):
self.member = 100
a = A()
print(a.member, a.nomember)
This is the output i got after running the code:
$ pylint -E test.py -f json
[
{
"type": "error",
"module": "test",
"obj": "",
"line": 11,
"column": 16,
"path": "test.py",
"symbol": "no-member",
"message": "Instance of 'A' has no 'nomember' member",
"message-id": "E1101"
}
]
You can see that now it is not giving this error "Instance of '' has no 'Table' member".
This link demonstrates some more useful information about pylint message control:
https://pylint.readthedocs.io/en/latest/user_guide/message-control.html
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.