web2py and pylint

280 views
Skip to first unread message

Alan Evangelista

unread,
Dec 2, 2014, 8:06:18 PM12/2/14
to web...@googlegroups.com
pylint checks fail on web2py controllers and models because web2py automatically imports several modules/classes/variables at runtime. I assume this is a known issue and there is no workaround?

Leonel Câmara

unread,
Dec 4, 2014, 9:42:00 AM12/4/14
to web...@googlegroups.com
This pylint plugin by Derek seems pretty good

I have to check how to make SublimeLinter use it because it does get annoying.

Andy Pardue

unread,
Dec 8, 2014, 2:45:24 PM12/8/14
to web...@googlegroups.com
When I was using sublime to develop web2py I would do imports under a False.
This would help with auto complete as well.
I use the pycharm now and it has web2py support that takes care of the way web2py use the libs.

if 0:  # for IDE's to find the imports for the globals
    from gluon.globals import *
    from gluon.html import *
    from gluon.http import *
    from gluon.tools import *
    from gluon.sql import *
    from gluon.validators import *
    from gluon.languages import translator as T

    from gluon.sqlhtml import SQLFORM, SQLTABLE, form_factory
    session = Session()
    request = Request()
    response = Response()
    crud = Crud()
    db = DAL('sqlite://storage.sqlite')
    auth = Auth(globals(), None)

flagist0

unread,
Dec 9, 2014, 10:28:08 AM12/9/14
to web...@googlegroups.com
Hello!
Yes, it is a known issue and there is a pylint plugin to fix it: https://github.com/dsludwig/pylint-web2py
The problem with it is that it relies on old Pylint API, so it doesn't work after version of 1.0

I updated it to support new Pylint (Astroid) API and added ability to find web2py modules (in application modules folder, in gluon etc).
And I sent dsludwig a pull request, but he didn't reply.

So you can find it here: https://github.com/flagist0/pylint-web2py
The easiest way to install it is to use this command:  pip install git+git://github.com/flagist0/pylint-web2py.git

Massimo Di Pierro

unread,
Dec 9, 2014, 10:04:17 PM12/9/14
to web...@googlegroups.com
perhaps we should include this in script?

flagist0

unread,
Dec 11, 2014, 11:33:15 AM12/11/14
to web...@googlegroups.com


On Wednesday, December 10, 2014 7:04:17 AM UTC+4, Massimo Di Pierro wrote:
perhaps we should include this in script?

Pylint expects the plugins to be installed system-wide, so it's better to use this plugin as a separate package.
But I'll register my version of the plugin on PyPI so it can be installed without git.

Prasad Muley

unread,
Dec 17, 2014, 10:02:23 AM12/17/14
to web...@googlegroups.com
Hi Flagist,


         I've installed pylint-web2py plugin by downloading from flagist-pylint-web2py github.

I've checked whether pylint-web2py plugin is successfully installed or not using following command:

$ pip freeze | grep pylint-web2py                                                                                                    [20:22:13]
pylint-web2py==0.1.2

I am getting following an error If I run following commands.

$ pylint -E --load-plugins pylint-web2py applications/asdf/scripts/asdf.py

Traceback (most recent call last):
  File "/usr/local/bin/pylint", line 9, in <module>
    load_entry_point('pylint==1.4.0', 'console_scripts', 'pylint')()
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/__init__.py", line 23, in run_pylint
    Run(sys.argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py", line 1193, in __init__
    linter.load_plugin_modules(self._plugins)
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py", line 469, in load_plugin_modules
    module = load_module_from_name(modname)
  File "/usr/local/lib/python2.7/dist-packages/astroid-1.3.2-py2.7.egg/astroid/modutils.py", line 135, in load_module_from_name
    return load_module_from_modpath(dotted_name.split('.'), path, use_sys)
  File "/usr/local/lib/python2.7/dist-packages/astroid-1.3.2-py2.7.egg/astroid/modutils.py", line 177, in load_module_from_modpath
    mp_file, mp_filename, mp_desc = imp.find_module(part, path)
ImportError: No module named pylint-web2py

Or

$ pylint '--load-plugins=pylint-web2py' applications/asdf/scripts/asdf.py                                             
Traceback (most recent call last):
  File "/usr/local/bin/pylint", line 9, in <module>
    load_entry_point('pylint==1.4.0', 'console_scripts', 'pylint')()
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/__init__.py", line 23, in run_pylint
    Run(sys.argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py", line 1193, in __init__
    linter.load_plugin_modules(self._plugins)
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.4.0-py2.7.egg/pylint/lint.py", line 469, in load_plugin_modules
    module = load_module_from_name(modname)
  File "/usr/local/lib/python2.7/dist-packages/astroid-1.3.2-py2.7.egg/astroid/modutils.py", line 135, in load_module_from_name
    return load_module_from_modpath(dotted_name.split('.'), path, use_sys)
  File "/usr/local/lib/python2.7/dist-packages/astroid-1.3.2-py2.7.egg/astroid/modutils.py", line 177, in load_module_from_modpath
    mp_file, mp_filename, mp_desc = imp.find_module(part, path)
ImportError: No module named pylint-web2py

Mandar Vaze

unread,
Dec 17, 2014, 12:40:31 PM12/17/14
to web...@googlegroups.com
Can you share the entire "pip freeze" output ?
Especially Astoid and logilab-common versions/details ?

https://bitbucket.org/logilab/pylint says "Pylint requires the astroid (the later the better; formerly known as logilab-astng) and logilab-common (version >= 0.53) packages"

This may provide additional clues.

-Mandar

Prasad Muley

unread,
Dec 17, 2014, 1:12:33 PM12/17/14
to web...@googlegroups.com
Hi Mandar,

          I've installed those packages. Pylint is working as expected but Pylint-web2py plugin isn't working as explained above.

$ pip freeze | grep logilab                                                                                                          
logilab-astng==0.24.3
logilab-common==0.63.2


$ pip freeze | grep astroid                                                                                                          
astroid==1.3.2



--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/db6NRkkMhGw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Thanks and Regards
Prasad M. Muley
Programmer at One Delta Synergies Pvt Ltd. | PICT 2013

“Pretty much everything on the web uses those two things: C and UNIX,” - Dennis Ritchie
                               http://www.cs.bell-labs.com/who/dmr/        

flagist0

unread,
Dec 17, 2014, 4:50:52 PM12/17/14
to
Hello Prasad!
Yes, it is a strange naming convention bug inherited from original project: repository is called pylint-web2py, but the plugin itself is called pylint_web2py (note the underscore).
So you'll have to call pylint like this: pylint -E --load-plugins pylint_web2py applications/asdf/scripts/asdf.py

Prasad Muley

unread,
Dec 18, 2014, 1:22:30 AM12/18/14
to web...@googlegroups.com
Hello Flagist,

           pylint -E --load-plugins pylint_web2py applications/asdf/scripts/asdf.py command. 
My bad to not recognize difference between pylint-web2py and pylint_web2py

Thanks for quick reply.


On Thu, Dec 18, 2014 at 3:20 AM, flagist0 <flag...@gmail.com> wrote:
Hello Prasad!
Yes, it is a strange naming convention bug inherited from original problem: repository is called pylint-web2py, but the plugin itself is called pylint_web2py (note the underscore).
So you'll to call pylint like this: pylint -E --load-plugins pylint_web2py applications/asdf/scripts/asdf.py




On Wednesday, December 17, 2014 7:02:23 PM UTC+4, Prasad Muley wrote:

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/db6NRkkMhGw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages