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

Need instructions about pylint/pychecker setup #674

Closed
patrakov opened this issue Feb 8, 2013 · 6 comments
Closed

Need instructions about pylint/pychecker setup #674

patrakov opened this issue Feb 8, 2013 · 6 comments

Comments

@patrakov
Copy link

patrakov commented Feb 8, 2013

Any attempt to run pylint or pychecker on anything that uses any Flask extension, e.g.:

from flask.ext.login import user_logged_in, user_logged_out

produces errors like the following:

F:  5,0: Unable to import 'flask.ext.login'
E:  5,0: No name 'login' in module 'flask.ext'

Some documentation is needed how to coerce pylint and pychecker into understanding how flask.ext.login is imported.

@hellysmile
Copy link

thats looks that you are using virtualenv, but your pylint\pychecker\pep8\pyflakes\flake8 installed at system globally

@patrakov
Copy link
Author

patrakov commented Feb 8, 2013

No virtualenv is used here. All of flask, flask-login, pylint, pychecker and pyflakes are installed system-wide. Pylint is started as follows:

PYTHONPATH=. pylint cabinet

i.e. the modules related to "cabinet" are not installed system-wide, but they import flask-related modules from the global installation. And they work when imported from the command line or from a script.

@ghost
Copy link

ghost commented Feb 8, 2013

Well, actually, module flask.ext.login does not exists: it's just a "shortcut" to module flask_login, implemented with sys.meta_path (check out Python docs and Flask implementation).

PS @patrakov: that's the output of Pylint or Pychecker?

@patrakov
Copy link
Author

patrakov commented Feb 8, 2013

This is the minimal test file demonstrating the problem (save as cabinet.py):

from flask import Flask
from flask.ext.login import user_logged_in, user_logged_out
from flask.ext.babel import Babel

def create_app():
    app = Flask(__name__)
    babel = Babel(app)
    return app

This is the beginning of the output from pylint:

No config file found, using default configuration
************* Module cabinet
C:  1,0: Missing docstring
F:  2,0: Unable to import 'flask.ext.login'
E:  2,0: No name 'login' in module 'flask.ext'
F:  3,0: Unable to import 'flask.ext.babel'
E:  3,0: No name 'babel' in module 'flask.ext'
C:  5,0:create_app: Missing docstring
W:  7,4:create_app: Unused variable 'babel'
W:  2,0: Unused import user_logged_out
W:  2,0: Unused import user_logged_in

This is the output from pychecker:

Processing module cabinet (cabinet)...
  Caught exception importing module cabinet:
    File "/usr/lib64/python2.7/site-packages/pychecker/pcmodules.py", line 540, in setupMainCode()
      module = imp.load_module(self.moduleName, handle, filename, smt)
    File "cabinet.py", line 3, in <module>()
      from flask.ext.babel import Babel
    File "/usr/lib64/python2.7/site-packages/flask/exthook.py", line 61, in load_module()
      __import__(realname)
    File "/usr/lib64/python2.7/site-packages/flaskext/babel.py", line 21, in <module>()
      from babel import dates, numbers, support, Locale
    File "/usr/lib64/python2.7/site-packages/babel/__init__.py", line 33, in <module>()
      from pkg_resources import get_distribution, ResolutionError
    File "/usr/lib64/python2.7/site-packages/pkg_resources.py", line 2793, in <module>()
      _declare_state('object', working_set = WorkingSet())
    File "/usr/lib64/python2.7/site-packages/pkg_resources.py", line 442, in __init__()
      self.add_entry(entry)
    File "/usr/lib64/python2.7/site-packages/pkg_resources.py", line 457, in add_entry()
      for dist in find_distributions(entry, True):
    File "/usr/lib64/python2.7/site-packages/pkg_resources.py", line 1704, in find_distributions()
      importer = get_importer(path_item)
    File "/usr/lib64/python2.7/pkgutil.py", line 384, in get_importer()
      importer = path_hook(path_item)
  TypeError: must be string, not None

Warnings...

cabinet:1: NOT PROCESSED UNABLE TO IMPORT

@malicustommade
Copy link

I hit this too. There is this:

http://engineering.pave.com/post/51820567994/welcome-linting-flask-ext

@mitsuhiko
Copy link
Contributor

I think this should be covered elsewhere. Just for the record: flask.ext.foo does not have to be used, you can use flask_foo with new extensions and flaskext.foo with old ones. The flask.ext module mainly exists so that transitions for users is less painful.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants