Pylint: astroid.exceptions.InferenceError: Empty return iterator

Created on 26 Jul 2018  路  6Comments  路  Source: PyCQA/pylint

Steps to reproduce

Pylint fails with a traceback when we try to analyze anaconda.

The problem seems to be in this file, but I don't know where to look for the main cause:
https://github.com/rhinstaller/anaconda/blob/modularization-devel/pyanaconda/payload/livepayload.py

Current behavior

Traceback (most recent call last):
  File "/usr/bin/pylint-3", line 11, in <module>
    load_entry_point('pylint==2.0.0', 'console_scripts', 'pylint')()
  File "/usr/lib/python3.7/site-packages/pylint/__init__.py", line 19, in run_pylint
    Run(sys.argv[1:])
  File "/usr/lib/python3.7/site-packages/pylint/lint.py", line 1394, in __init__
    linter.check(args)
  File "/usr/lib/python3.7/site-packages/pylint/lint.py", line 801, in check
    self._do_check(files_or_modules)
  File "/usr/lib/python3.7/site-packages/pylint/lint.py", line 938, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/usr/lib/python3.7/site-packages/pylint/lint.py", line 1018, in check_astroid_module
    walker.walk(ast_node)
  File "/usr/lib/python3.7/site-packages/pylint/utils.py", line 1159, in walk
    self.walk(child)
  File "/usr/lib/python3.7/site-packages/pylint/utils.py", line 1159, in walk
    self.walk(child)
  File "/usr/lib/python3.7/site-packages/pylint/utils.py", line 1159, in walk
    self.walk(child)
  [Previous line repeated 1 more times]
  File "/usr/lib/python3.7/site-packages/pylint/utils.py", line 1156, in walk
    cb(astroid)
  File "/usr/lib/python3.7/site-packages/pylint/checkers/typecheck.py", line 748, in visit_attribute
    if not [n for n in owner.getattr(node.attrname)
  File "/usr/lib/python3.7/site-packages/astroid/objects.py", line 181, in getattr
    return list(self.igetattr(name, context=context))
  File "/usr/lib/python3.7/site-packages/astroid/objects.py", line 170, in igetattr
    for value in inferred.infer_call_result(self, context):
  File "/usr/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 1621, in infer_call_result
    raise exceptions.InferenceError('Empty return iterator')
astroid.exceptions.InferenceError: Empty return iterator

Expected behavior

No traceback.

pylint --version output

pylint 2.0.0
astroid 2.0
Python 3.7.0 (default, Jul 15 2018, 06:08:44)
[GCC 8.1.1 20180626 (Red Hat 8.1.1-4)]

astroid bug

Most helpful comment

Thanks folks for the reproducing example! This should be fixed now in astroid's master. If I'll find some time this week, I'll do a 2.1 release.

All 6 comments

I'm having trouble reproducing. Can you give me a pip freeze of your installed packages? + anaconda commit hash?

I've reproduced this error in the following version:

C:\Temp> py -3 -m pylint --version
__main__.py 2.0.1
astroid 2.0.1
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)]

It seems to be related to fetching properties through super() that were initially defined on an abstract base class. The code to reproduce it is:

from abc import ABC, abstractmethod

class MyBaseABC(ABC):
    @property
    @abstractmethod
    def prop(self):
        """Example property"""

class MyBase(MyBaseABC):
    @property
    def prop(self):
        return 11

class MyChild(MyBase):
    @property
    def prop(self):
        return super().prop + 2

c = MyChild()
print(c.prop)

To reproduce the error, save the above code snippet as test.py and run:
py -3 -m pylint test.py

Thanks @elpollouk! I can reproduce on master

Thanks folks for the reproducing example! This should be fixed now in astroid's master. If I'll find some time this week, I'll do a 2.1 release.

This appears to have been fixed (or at least was for my case) with Pylint 2.1. Thanks very much for the prompt fix!

Yep, updateing to Pylint 2.1.0 and asteroid 2.0.2 has solved this for me as well.

Thanks very much for the quick resolution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elirnm picture elirnm  路  3Comments

PCManticore picture PCManticore  路  3Comments

jrial picture jrial  路  3Comments

PCManticore picture PCManticore  路  3Comments

GergelyKalmar picture GergelyKalmar  路  3Comments