Open jamesjren opened 6 years ago
Thanks for reporting an issue! The thing with flask
is that we always had problems inferring flask
given the amount of metaprogramming it relies on.
I'm still seeing this problem with flask==2.2.2
and pylint==2.16.0
, when using APP.logger.info(...)
.
Typing is very well-defined (https://github.com/pallets/flask/blob/4ddb3f73baa5b60ed83d6bb48d0d447a0d8ab492/src/flask/app.py#L772), and using directly a log = logging.getLogger()
class with log.info(...)
does not produce the no-member false positive, so why is this flagged incorrectly in the case of Flask?
pylint does not use typing but its inference (which fail is the code is too dynamic), see #4813
I see. Is there a specific config in .pylintrc
that I can set to specifically ignore instances of Flask.logger.<method>
? There are too many in the code base to add pylint disable comments everywhere.
For anyone finding this issue, my current workaround is by defining the following in .pylintrc
[TYPECHECK]
generated-members=
logger.debug,
logger.info,
logger.warning,
logger.error,
logger.exception,
app.logger.debug,
app.logger.info,
app.logger.warning,
app.logger.error,
app.logger.exception,
APP.logger.debug,
APP.logger.info,
APP.logger.warning,
APP.logger.error,
APP.logger.exception
Steps to reproduce
minimal.py
:from flask import Flask
app = Flask(name)
@app.route('/') def _foo(): app.logger.debug('bar') return 'baz'
***** Module minimal minimal.py:9:4: E1101: Method 'logger' has no 'debug' member (no-member)
pylint 2.1.1 astroid 2.0.4