Using flask's app.logger
member functions (such as app.logger.error
) causes pylint
to report E1101
(no-member
) errors, even though these members of app.logger
are defined at runtime.
This can be reproduced by using the following files:
app.py
import flask
app = flask.Flask(__name__)
@app.route('/')
def say_hello():
app.logger.debug('A debug message')
app.logger.error('An error message')
return 'hello'
requirements.txt
pylint==2.1.0
Flask==1.0.2
Sample commands for reproducing the issue, using virtualenv
:
(Python 3.5 is used here, but the issue is not specific to that version)
virtualenv --python=python3.5 env
source env/bin/activate
pip install pip==18.0
pip install -r requirements.txt
And finally, running pylint
:
pylint -E app
Returns these errors:
************* Module app
app.py:9:4: E1101: Method 'logger' has no 'debug' member (no-member)
app.py:10:4: E1101: Method 'logger' has no 'error' member (no-member)
Is there a good way to avoid these false positives?