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

Comments

Projects
None yet
4 participants
@patrakov
Copy link

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

This comment has been minimized.

Copy link

commented Feb 8, 2013

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

@patrakov

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

commented Aug 1, 2013

@mitsuhiko

This comment has been minimized.

Copy link
Member

commented Aug 2, 2013

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.

@mitsuhiko mitsuhiko closed this Aug 2, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.