Skip to content
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

E1101 on Flask.logger.<method> #2586

Open
jamesjren opened this issue Nov 7, 2018 · 5 comments
Open

E1101 on Flask.logger.<method> #2586

jamesjren opened this issue Nov 7, 2018 · 5 comments
Labels
Bug 🪲 High priority Issue with more than 10 reactions Lib specific 💅 This affect the code from a particular library Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) Needs PR This issue is accepted, sufficiently specified and now needs an implementation

Comments

@jamesjren
Copy link

Steps to reproduce

  1. create minimal.py:
#pylint: disable=missing-docstring,invalid-name

from flask import Flask

app = Flask(__name__)

@app.route('/')
def _foo():
    app.logger.debug('bar')
    return 'baz'
  1. run pylint minimal.py

Current behavior

************* Module minimal
minimal.py:9:4: E1101: Method 'logger' has no 'debug' member (no-member)

Expected behavior

No errors

pylint --version output

pylint 2.1.1
astroid 2.0.4

Additional information

This is for Flask version 1.0.2, which is current as of the date of this report.

@PCManticore
Copy link
Contributor

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.

@PCManticore PCManticore added Bug 🪲 Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) labels Nov 23, 2018
abij added a commit to abij/car_lookup_slackbot that referenced this issue Feb 8, 2019
@Pierre-Sassoulas Pierre-Sassoulas added Lib specific 💅 This affect the code from a particular library High priority Issue with more than 10 reactions Needs PR This issue is accepted, sufficiently specified and now needs an implementation labels Jun 29, 2022
@fmigneault
Copy link

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?

@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Feb 10, 2023

pylint does not use typing but its inference (which fail is the code is too dynamic), see #4813

@fmigneault
Copy link

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.

@fmigneault
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 High priority Issue with more than 10 reactions Lib specific 💅 This affect the code from a particular library Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

No branches or pull requests

4 participants