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

Missing member hint fails when object has duplicated bases #4687

Closed
doranid opened this issue Jul 7, 2021 · 1 comment · Fixed by #4688
Closed

Missing member hint fails when object has duplicated bases #4687

doranid opened this issue Jul 7, 2021 · 1 comment · Fixed by #4688
Labels
Blocker 🙅 Blocks the next release Crash 💥 A bug that makes pylint crash
Milestone

Comments

@doranid
Copy link
Contributor

doranid commented Jul 7, 2021

Steps to reproduce

Given a file b.py:

# pylint: disable=C0114, C0115, R0205, E0241, C0116, W0104
class Klass(object, object):
    def get(self):
        self._non_existent_attribute

Current behavior

Result of pylint a.py:

➜  d pylint b.py
Exception on node <Attribute._non_existent_attribute l.7 at 0x10e80d898> in file 'b.py'
Traceback (most recent call last):
  File "bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "pylint/__init__.py", line 24, in run_pylint
    PylintRun(sys.argv[1:])
  File "pylint/lint/run.py", line 384, in __init__
    linter.check(args)
  File "pylint/lint/pylinter.py", line 974, in check
    self.get_ast, self._iterate_file_descrs(files_or_modules)
  File "pylint/lint/pylinter.py", line 1007, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "pylint/lint/pylinter.py", line 1033, in _check_file
    check_astroid_module(ast_node)
  File "pylint/lint/pylinter.py", line 1171, in check_astroid_module
    ast_node, walker, rawcheckers, tokencheckers
  File "pylint/lint/pylinter.py", line 1215, in _check_astroid_module
    walker.walk(ast_node)
  File "pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  File "pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  File "pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  [Previous line repeated 1 more time]
  File "pylint/utils/ast_walker.py", line 74, in walk
    callback(astroid)
  File "pylint/checkers/typecheck.py", line 1033, in visit_attribute
    msg, hint = self._get_nomember_msgid_hint(node, owner)
  File "pylint/checkers/typecheck.py", line 1055, in _get_nomember_msgid_hint
    self.config.missing_member_max_choices,
  File "pylint/checkers/typecheck.py", line 244, in _missing_member_hint
    names = _similar_names(owner, attrname, distance_threshold, max_choices)
  File "pylint/checkers/typecheck.py", line 222, in _similar_names
    names = _node_names(owner)
  File "functools.py", line 807, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "pylint/checkers/typecheck.py", line 189, in _
    mro = node.mro()[1:]
  File "astroid/scoped_nodes.py", line 2983, in mro
    return self._compute_mro(context=context)
  File "astroid/scoped_nodes.py", line 2971, in _compute_mro
    unmerged_mro = list(clean_duplicates_mro(unmerged_mro, self, context))
  File "astroid/scoped_nodes.py", line 157, in clean_duplicates_mro
    context=context,
astroid.exceptions.DuplicateBasesError: Duplicates found in MROs (Klass), (object), (object), (object, object) for <ClassDef.Klass l.2 at 0x10e80d470>.

Expected behavior

Should not fail hard.

pylint --version output

pylint 2.9.3
astroid 2.6.2
Python 3.6.12 (default, Feb 6 2021, 10:30:58)
[GCC Apple LLVM 12.0.0 (clang-1200.0.32.29)]


@Pierre-Sassoulas Pierre-Sassoulas added Blocker 🙅 Blocks the next release Crash 💥 A bug that makes pylint crash Needs astroid update Needs an astroid update (probably a release too) before being mergable labels Jul 8, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.9.4 milestone Jul 8, 2021
@Pierre-Sassoulas
Copy link
Member

Thank you for opening the issue, nice catch.

@Pierre-Sassoulas Pierre-Sassoulas removed the Needs astroid update Needs an astroid update (probably a release too) before being mergable label Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocker 🙅 Blocks the next release Crash 💥 A bug that makes pylint crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants