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 with astroid 2.5 raises an exception when checking aiohttp or any library that depends on aiohttp #4131

Closed
danking opened this issue Feb 23, 2021 · 3 comments · Fixed by pylint-dev/astroid#916 or PennyDreadfulMTG/Penny-Dreadful-Tools#8447
Labels
Blocker 🙅 Blocks the next release Crash 💥 A bug that makes pylint crash
Milestone

Comments

@danking
Copy link

danking commented Feb 23, 2021

Steps to reproduce

  1. In a fresh environment, pip3 install pylint
  2. In that environment, pylint aiohttp

Current behavior

Traceback (most recent call last):
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/decorators.py", line 34, in cached
    return cache[func]
KeyError: <bound method ClassDef.slots of <ClassDef.AbstractResource l.76 at 0x7f83c4b42490>>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dking/miniconda3/envs/garbage/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/lint/run.py", line 349, in __init__
    linter.check(args)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 863, in check
    self.get_ast, self._iterate_file_descrs(files_or_modules)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 896, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 922, in _check_file
    check_astroid_module(ast_node)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 1055, in check_astroid_module
    ast_node, walker, rawcheckers, tokencheckers
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 1099, in _check_astroid_module
    walker.walk(ast_node)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/utils/ast_walker.py", line 72, in walk
    callback(astroid)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/checkers/typecheck.py", line 1037, in visit_assign
    self._check_assignment_from_function_call(node)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/checkers/typecheck.py", line 1047, in _check_assignment_from_function_call
    function_node = safe_infer(node.value.func)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/pylint/checkers/utils.py", line 1143, in safe_infer
    value = next(infer_gen)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/node_classes.py", line 365, in infer
    yield from self._infer(context, **kwargs)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/decorators.py", line 134, in raise_if_nothing_inferred
    yield next(generator)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/decorators.py", line 98, in wrapped
    res = next(generator)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/bases.py", line 136, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/node_classes.py", line 379, in infer
    for i, result in enumerate(generator):
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/decorators.py", line 134, in raise_if_nothing_inferred
    yield next(generator)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/decorators.py", line 98, in wrapped
    res = next(generator)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/bases.py", line 136, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/node_classes.py", line 379, in infer
    for i, result in enumerate(generator):
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/decorators.py", line 134, in raise_if_nothing_inferred
    yield next(generator)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/decorators.py", line 95, in wrapped
    generator = _func(node, context, **kwargs)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/inference.py", line 273, in infer_import_from
    module = self.do_import_module()
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/mixins.py", line 100, in do_import_module
    modname, level=level, relative_only=level and level >= 1
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 646, in import_module
    return MANAGER.ast_from_module_name(absmodname)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/manager.py", line 191, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/manager.py", line 100, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/builder.py", line 139, in file_build
    return self._post_build(module, encoding)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/builder.py", line 159, in _post_build
    self.delayed_assattr(delayed)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/builder.py", line 235, in delayed_assattr
    if not _can_assign_attr(inferred, node.attrname):
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/builder.py", line 60, in _can_assign_attr
    slots = node.slots()
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/decorators.py", line 36, in cached
    cache[func] = result = func(*args, **kwargs)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 2838, in slots
    slots = list(grouped_slots())
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 2823, in grouped_slots
    for cls in self.mro()[:-1]:
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 2909, in mro
    return self._compute_mro(context=context)
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 2898, in _compute_mro
    unmerged_mro = list(clean_duplicates_mro(unmerged_mro, self, context))
  File "/Users/dking/miniconda3/envs/garbage/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 114, in clean_duplicates_mro
    context=context,
astroid.exceptions.DuplicateBasesError: Duplicates found in MROs (AbstractResource), (_GenericAlias, _Final, object), (_GenericAlias, _Final, object), (_GenericAlias, _GenericAlias) for <ClassDef.AbstractResource l.76 at 0x7f83c4b42490>.

Expected behavior

No exceptions.

pylint --version output

(garbage) # pylint --version  
zsh: /usr/local/bin/pylint: bad interpreter: /usr/local/opt/python/bin/python3.7: no such file or directory
pylint 2.6.0
astroid 2.5
Python 3.7.9 (default, Aug 31 2020, 07:22:35) 
[Clang 10.0.0 ]

@cdce8p
Copy link
Member

cdce8p commented Feb 23, 2021

This issue is similar to #4093 and pylint-dev/astroid#905
I've already opened a PR to address it for the next (bugfix) release: pylint-dev/astroid#910

@cdce8p
Copy link
Member

cdce8p commented Feb 28, 2021

@danking Pylint 2.7.2 has just been released. That should have fixed the issue. Just to be sure, can you test if everything works?

@postlund
Copy link

postlund commented Mar 1, 2021

Works for me! 👍

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
4 participants