When I test a module that uses Requests, pylint has a fit and claims that the various members of the Request object that I use do not exist. How can I fix this? I already run pylint with the --generated-members=objects option.
For example, this code runs fine:
import requests
response = requests.get('https://github.com/timeline.json')
print response.content
But pylint claims the field does not exist:
ID:E1103 Instance of 'Request' has no 'content' member (but some types could not be inferred)
pylint
warning and error messages can be configured.
First of all you can write a ${HOME}/.pylintrc
to disable some messages for all pylint checks. You can generate a default version of this file using the --generate-rc-file
option.
(See this question for a bit more information).
You can also do the configuration inside the sources analyzed. For example putting some comments at the beginning of the file. This will disable the messages for the whole file.
The comment are in the form: #pylint: disable=warning-code
, and "warning-code" is one of the list found here.
You can also disable messages locally, putting the comment before or on the side of a statement/expression.
For example, this disables the "C0322" warning for the code inside the function:
def my_func():
#C0322 -> no space between operand and operator
#pylint: disable=C0322
return a+b
While putting the comment on the right disables it for the single line of code:
def my_func():
return a+b #pylint: disable=C0322
I think in your case you could either put a comment at the beginning of the functions that use the request
, or, if you do not access it many times, you could put a comment on the right of the statements.