Pylint: Python3Checker causes traceback when trying to run pylint

Created on 5 Jan 2017  Â·  11Comments  Â·  Source: PyCQA/pylint

Steps to reproduce

  1. Install latest source in code a virtual environment
  2. python setup.py develop
  3. pylint

Current behavior

Traceback (most recent call last):
File "/bin/pylint", line 8, in
execfile(__file__)
File "/home/megger/pylint/bin/pylint", line 3, in
run_pylint()
File "/home/megger/pylint/pylint/__init__.py", line 13, in run_pylint
Run(sys.argv[1:])
File "/home/megger/pylint/pylint/lint.py", line 1220, in __init__
linter.load_default_plugins()
File "/home/megger/pylint/pylint/lint.py", line 453, in load_default_plugins
checkers.initialize(self)
File "/home/megger/pylint/pylint/checkers/__init__.py", line 114, in initialize
register_plugins(linter, __path__[0])
File "/home/megger/pylint/pylint/utils.py", line 992, in register_plugins
module = modutils.load_module_from_file(join(directory, filename))
File "/usr/lib/python2.7/site-packages/astroid-1.4.9-py2.7.egg/astroid/modutils.py", line 268, in load_module_from_file
return load_module_from_modpath(modpath, path, use_sys)
File "/usr/lib/python2.7/site-packages/astroid-1.4.9-py2.7.egg/astroid/modutils.py", line 229, in load_module_from_modpath
module = imp.load_module(curname, mp_file, mp_filename, mp_desc)
File "/home/megger/pylint/pylint/checkers/python3.py", line 100, in
class Python3Checker(checkers.BaseChecker):
File "/home/megger/pylint/pylint/checkers/python3.py", line 501, in Python3Checker
'sys.version_info < (3, 0)',
AttributeError: 'module' object has no attribute 'extract_node'

Expected behavior

pylint should run, displaying options

pylint --version output

2.0 Latest as of Jan 5, 2017 2:06PM CST

After investigation bug was introduced in commit https://github.com/PyCQA/pylint/commit/c002c48a9b8d98b43262e045243af2a80cb8a1f3

Removing lines 490-502 removes the issue and pylint can run again. It appears astroid doesn't have an extract_node method

Most helpful comment

Doesn't the post I made 1 hour ago prove that I am using master of astroid? If not, could you tell me how to correct that?

All 11 comments

You need to run pylint 2.0 with astroid 1.5.0, taken from the astroid's repository.

Hi @PCManticore, I still have the issue with astroid 1.5.0 installed.

Traceback (most recent call last): File "/usr/bin/pylint", line 11, in <module> load_entry_point('pylint==1.7.0', 'console_scripts', 'pylint')() File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/__init__.py", line 13, in run_pylint Run(sys.argv[1:]) File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/lint.py", line 1220, in __init__ linter.load_default_plugins() File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/lint.py", line 453, in load_default_plugins checkers.initialize(self) File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/checkers/__init__.py", line 114, in initialize register_plugins(linter, __path__[0]) File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/utils.py", line 992, in register_plugins module = modutils.load_module_from_file(join(directory, filename)) File "/usr/lib/python2.7/site-packages/astroid/modutils.py", line 268, in load_module_from_file return load_module_from_modpath(modpath, path, use_sys) File "/usr/lib/python2.7/site-packages/astroid/modutils.py", line 229, in load_module_from_modpath module = imp.load_module(curname, mp_file, mp_filename, mp_desc) File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/checkers/python3.py", line 100, in <module> class Python3Checker(checkers.BaseChecker): File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/checkers/python3.py", line 501, in Python3Checker 'sys.version_info < (3, 0)', AttributeError: 'module' object has no attribute 'extract_node'

i'm also running into the same issue while trying to build from source (because I want to use the latest 1.7.0 version to use "sy" flag
using python: 2.7

cloned repo
ran python setup.py install
which was successful with "Using /usr/local/lib/python2.7/dist-packages
Finished processing dependencies for pylint==1.7.0"

but on checking version, fails with

Finished processing dependencies for pylint==1.7.0
ubuntu@ip-sss:~/scripts/pooja/pylint$ pylint --version
Traceback (most recent call last):
  File "/usr/local/bin/pylint", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/home/ubuntu/scripts/pooja/pylint/bin/pylint", line 3, in <module>
    run_pylint()
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/__init__.py", line 13, in run_pylint
    Run(sys.argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/lint.py", line 1220, in __init__
    linter.load_default_plugins()
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/lint.py", line 453, in load_default_plugins
    checkers.initialize(self)
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/checkers/__init__.py", line 114, in initialize
    register_plugins(linter, __path__[0])
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/utils.py", line 992, in register_plugins
    module = modutils.load_module_from_file(join(directory, filename))
  File "/usr/local/lib/python2.7/dist-packages/astroid/modutils.py", line 268, in load_module_from_file
    return load_module_from_modpath(modpath, path, use_sys)
  File "/usr/local/lib/python2.7/dist-packages/astroid/modutils.py", line 229, in load_module_from_modpath
    module = imp.load_module(curname, mp_file, mp_filename, mp_desc)
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/checkers/python3.py", line 100, in <module>
    class Python3Checker(checkers.BaseChecker):
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/checkers/python3.py", line 501, in Python3Checker
    'sys.version_info < (3, 0)',
AttributeError: 'module' object has no attribute 'extract_node'

@p00j4 Try installing the master branch of astroid, and then rerunning setup.py

I think i am on master of astroid but still have the issue:

~/source/astroid # git branch -a

  • master
    remotes/origin/1.4.0
    remotes/origin/2.0
    remotes/origin/HEAD -> origin/master
    remotes/origin/master
    remotes/origin/revert-397-import_all
    remotes/origin/zipper

~/source/astroid # git pull
Already up-to-date.

Couldn't find your comments on Github. Let me see if reply in email works.

Which file were you talking about? My search didn't return any result:
find *.py -exec grep -H "astroid.extract_node" {} \;
find *.py -exec grep -H "frozenset" {} \;

On Tue, Mar 21, 2017 at 8:43 AM, Pooja Shah notifications@github.com
wrote:

as work around, since i'm on python 2.7, have just commented the block
itself, hoping for no side effect to appear in near future.
"""if (3, 4) <= sys.version_info < (3, 4, 4):

Python 3.4.0 -> 3.4.3 has a bug which breaks repr_tree():

https://bugs.python.org/issue23572

_python_2_tests = frozenset()
else:
_python_2_tests = frozenset(
[astroid.extract_node(x).repr_tree() for x in [
'sys.version_info[0] == 2',
'sys.version_info[0] < 3',
'sys.version_info == (2, 7)',
'sys.version_info <= (2, 7)',
'sys.version_info < (3, 0)',
]])
"""

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/PyCQA/pylint/issues/1270#issuecomment-288066976, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AHLlPYAJsmRT3LctLEenRuF2mN9ccFM3ks5rn8YNgaJpZM4LcE5p
.

sorry, that hadn't work so removed the comment. I hurried in replying by just checking "version" which gave me wrong indication that it would work, it now fails with a new error

Traceback (most recent call last):
  File "/usr/local/bin/pylint", line 11, in <module>
    load_entry_point('pylint==1.7.0', 'console_scripts', 'pylint')()
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/__init__.py", line 13, in run_pylint
    Run(sys.argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/lint.py", line 1220, in __init__
    linter.load_default_plugins()
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/lint.py", line 453, in load_default_plugins
    checkers.initialize(self)
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/checkers/__init__.py", line 114, in initialize
    register_plugins(linter, __path__[0])
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/utils.py", line 992, in register_plugins
    module = modutils.load_module_from_file(join(directory, filename))
  File "/usr/local/lib/python2.7/dist-packages/astroid-1.5.0-py2.7.egg/astroid/modutils.py", line 272, in load_module_from_file
    return load_module_from_modpath(modpath, path, use_sys)
  File "/usr/local/lib/python2.7/dist-packages/astroid-1.5.0-py2.7.egg/astroid/modutils.py", line 233, in load_module_from_modpath
    module = imp.load_module(curname, mp_file, mp_filename, mp_desc)
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/checkers/python3.py", line 100, in <module>
    class Python3Checker(checkers.BaseChecker):
  File "/usr/local/lib/python2.7/dist-packages/pylint-1.7.0-py2.7.egg/pylint/checkers/python3.py", line 501, in Python3Checker
    'sys.version_info < (3, 0)',
  File "/usr/local/lib/python2.7/dist-packages/astroid-1.5.0-py2.7.egg/astroid/node_classes.py", line 624, in repr_tree
    _repr_tree(self, result, set())
  File "build/bdist.linux-x86_64/egg/singledispatch.py", line 210, in wrapper
  File "/usr/local/lib/python2.7/dist-packages/astroid-1.5.0-py2.7.egg/astroid/node_classes.py", line 613, in _repr_node
    depth)
  File "build/bdist.linux-x86_64/egg/singledispatch.py", line 210, in wrapper
  File "/usr/local/lib/python2.7/dist-packages/astroid-1.5.0-py2.7.egg/astroid/node_classes.py", line 613, in _repr_node
    depth)
  File "build/bdist.linux-x86_64/egg/singledispatch.py", line 210, in wrapper
  File "build/bdist.linux-x86_64/egg/singledispatch.py", line 191, in dispatch
  File "build/bdist.linux-x86_64/egg/singledispatch.py", line 142, in _find_impl
  File "build/bdist.linux-x86_64/egg/singledispatch.py", line 130, in _compose_mro
  File "build/bdist.linux-x86_64/egg/singledispatch.py", line 84, in _c3_mro
  File "build/bdist.linux-x86_64/egg/singledispatch.py", line 88, in _c3_mro
  File "build/bdist.linux-x86_64/egg/singledispatch.py", line 39, in _c3_merge
RuntimeError: Inconsistent hierarchy

though @t0w2 if you want to try, its there only "pylint/checkers/python3.py" -> line 500 as found in stacktrace, just try installing again after commenting the entire block

Thanks @p00j4 ! Commented out the code but got another traceback now.

Traceback (most recent call last):
File "/usr/bin/pylint", line 11, in
load_entry_point('pylint==1.7.0', 'console_scripts', 'pylint')()
File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/__init__.py", line 13, in run_pylint
Run(sys.argv[1:])
File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/lint.py", line 1300, in __init__
linter.check(args)
File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/lint.py", line 726, in check
self._do_check(files_or_modules)
File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/lint.py", line 837, in _do_check
for descr in self.expand_files(files_or_modules):
File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/lint.py", line 869, in expand_files
self.config.black_list_re)
File "/usr/lib/python2.7/site-packages/pylint-1.7.0-py2.7.egg/pylint/utils.py", line 876, in expand_modules
is_namespace = modutils.is_namespace(spec)
AttributeError: 'module' object has no attribute 'is_namespace'

I don't think you are using master's branch of astroid.

Doesn't the post I made 1 hour ago prove that I am using master of astroid? If not, could you tell me how to correct that?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PCManticore picture PCManticore  Â·  3Comments

pylint-bot picture pylint-bot  Â·  3Comments

glmdgrielson picture glmdgrielson  Â·  3Comments

DGalt picture DGalt  Â·  3Comments

adamtheturtle picture adamtheturtle  Â·  3Comments