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

pylint 1.9.x fails on Python 3.7 #2572

Closed
jbaum-cmcrc opened this issue Oct 26, 2018 · 1 comment
Closed

pylint 1.9.x fails on Python 3.7 #2572

jbaum-cmcrc opened this issue Oct 26, 2018 · 1 comment
Labels
Invalid Not a bug, already exists or already fixed

Comments

@jbaum-cmcrc
Copy link

There is currently no version of pylint that works on both Python 2.7 and Python 3.7, which are the two "stable" versions.

Steps to reproduce

  1. Install pylint==1.9.3 under Python 3.7
  2. Create a python module test.py which contains only the statement import datetime
  3. Run pylint test.py

Current behavior

An exception is raised, originally in astroid.decorators line 89; full traceback below. This is likely due to the changes introduced in PEP-479 - the current code explicitly raises StopIteration.

Expected behavior

Pylint outputs two messages (missing-docstring and unused-import).

This is the case with pylint 1.9.3 under earlier versions of python, and also the case with the latest pylint under Python 3.7.

pylint --version output

No config file found, using default configuration
pylint 1.9.3,
astroid 1.6.5
Python 3.7.0 (default, Sep 12 2018, 18:30:08)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]

Impact

There is no version of pylint which works under all currently supported versions of Python.

Full traceback

Traceback (most recent call last):
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 104, in wrapped
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/jbaum/qq/venv-37/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/__init__.py", line 16, in run_pylint
    Run(sys.argv[1:])
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/lint.py", line 1353, in __init__
    linter.check(args)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/lint.py", line 774, in check
    self._do_check(files_or_modules)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/lint.py", line 907, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/lint.py", line 986, in check_astroid_module
    walker.walk(ast_node)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/utils.py", line 1014, in walk
    self.walk(child)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/utils.py", line 1011, in walk
    cb(astroid)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/pylint/checkers/variables.py", line 1245, in visit_import
    module = next(node.infer_name_module(parts[0]))
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/context.py", line 71, in cache_generator
    for result in generator:
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/inference.py", line 194, in infer_import
    yield self.do_import_module(name)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/mixins.py", line 119, in do_import_module
    relative_only=level and level >= 1)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 593, in import_module
    return MANAGER.ast_from_module_name(absmodname)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/manager.py", line 154, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/manager.py", line 80, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/builder.py", line 153, in file_build
    return self._post_build(module, encoding)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/builder.py", line 173, in _post_build
    self.delayed_assattr(delayed)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/builder.py", line 232, in delayed_assattr
    for inferred in node.expr.infer():
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/bases.py", line 95, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/context.py", line 71, in cache_generator
    for result in generator:
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/bases.py", line 95, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/context.py", line 71, in cache_generator
    for result in generator:
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
    yield next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/inference.py", line 166, in infer_call
    for callee in self.func.infer(context):
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/context.py", line 71, in cache_generator
    for result in generator:
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
    yield next(generator)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/inference.py", line 259, in infer_attribute
    for obj in owner.igetattr(self.attrname, context):
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 2294, in igetattr
    attrs = self.getattr(name, context, class_context=class_context)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 2231, in getattr
    values += self._metaclass_lookup_attribute(name, context)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 2247, in _metaclass_lookup_attribute
    attrs.update(set(cls_attributes))
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 2253, in _get_attribute_from_metaclass
    class_context=True)
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 2227, in getattr
    for classnode in self.ancestors(recurs=True, context=context):
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 2046, in ancestors
    for baseobj in stmt.infer(context):
  File "/home/jbaum/qq/venv-37/lib/python3.7/site-packages/astroid/context.py", line 71, in cache_generator
    for result in generator:
RuntimeError: generator raised StopIteration
@PCManticore
Copy link
Contributor

@jbaum-cmcrc No, there is not. For 2.7 you need to use 1.9 while for 3.7 you need to use >=2.0. The reason for that is that Python 3.7 support couldn't have been added in pylint without dropping support for Python 2.

@PCManticore PCManticore added the Invalid Not a bug, already exists or already fixed label Oct 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Invalid Not a bug, already exists or already fixed
Projects
None yet
Development

No branches or pull requests

2 participants