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 crash on using double underscore function #4244

Closed
hyde-00 opened this issue Mar 17, 2021 · 2 comments
Closed

Pylint crash on using double underscore function #4244

hyde-00 opened this issue Mar 17, 2021 · 2 comments

Comments

@hyde-00
Copy link

hyde-00 commented Mar 17, 2021

Steps to reproduce

Minimum code to reproduce pylint crash:

from __future__ import absolute_import
from abc import abstractmethod

class ApplianceConfig:

    # Implemented in child class.
    def _get_details(self):
        pass

    def __generate_reponse_file_data(self):
        d = {}
        if len(self._get_details()):
            d['key'] = json.dumps(self._get_details())

Current behavior

Traceback (most recent call last):
  File "/opt/venv/lib64/python3.6/site-packages/astroid/decorators.py", line 135, in raise_if_nothing_inferred
    yield next(generator)
StopIteration: {'node': <Call l.12 at 0x7f734a9b1be0>, 'context': <astroid.context.InferenceContext object at 0x7f734a9bc888>}

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

Traceback (most recent call last):
  File "/opt/venv/bin/pylint", line 11, in <module>

▽
    sys.exit(run_pylint())
  File "/opt/venv/lib64/python3.6/site-packages/pylint/__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "/opt/venv/lib64/python3.6/site-packages/pylint/lint/run.py", line 358, in __init__
    linter.check(args)
  File "/opt/venv/lib64/python3.6/site-packages/pylint/lint/pylinter.py", line 863, in check
    self.get_ast, self._iterate_file_descrs(files_or_modules)
  File "/opt/venv/lib64/python3.6/site-packages/pylint/lint/pylinter.py", line 896, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/opt/venv/lib64/python3.6/site-packages/pylint/lint/pylinter.py", line 922, in _check_file
    check_astroid_module(ast_node)
  File "/opt/venv/lib64/python3.6/site-packages/pylint/lint/pylinter.py", line 1055, in check_astroid_module
    ast_node, walker, rawcheckers, tokencheckers
  File "/opt/venv/lib64/python3.6/site-packages/pylint/lint/pylinter.py", line 1099, in _check_astroid_module
    walker.walk(ast_node)
  File "/opt/venv/lib64/python3.6/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/opt/venv/lib64/python3.6/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/opt/venv/lib64/python3.6/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  [Previous line repeated 1 more time]
  File "/opt/venv/lib64/python3.6/site-packages/pylint/utils/ast_walker.py", line 72, in walk
    callback(astroid)
  File "/opt/venv/lib64/python3.6/site-packages/pylint/checkers/refactoring/len_checker.py", line 76, in visit_call
    instance = next(len_arg.infer())
  File "/opt/venv/lib64/python3.6/site-packages/astroid/node_classes.py", line 366, in infer
    yield from self._infer(context, **kwargs)
  File "/opt/venv/lib64/python3.6/site-packages/astroid/decorators.py", line 140, in raise_if_nothing_inferred
    raise exceptions.InferenceError(**error.args[0]) from error
astroid.exceptions.InferenceError: Inference failed for <Call l.12 at 0x7f734a9b1be0>.

Expected behavior

Pylint should not crash. I was using pylint==2.6.0 earlier and this crash was not observed.

Result of pylint --version output:

vpylint --version
pylint 2.7.2
astroid 2.5.1
Python 3.6.8 (default, Sep 26 2019, 11:57:09)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
@cdce8p
Copy link
Member

cdce8p commented Mar 17, 2021

I believe this is a duplicate of #4215 which is already fixed in the current master. Will be included in the next release.

@hippo91
Copy link
Contributor

hippo91 commented Apr 9, 2021

@hyde-00 thanks for your report. I confirm that the bug does not occur anymore with the master branch and as it seems to be a duplicate i close this issue.

@hippo91 hippo91 closed this as completed Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants