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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Astroid 2.5] astroid.exceptions.DuplicateBasesError: Duplicates found in MROs (OrderedSet) #4093

Closed
Toilal opened this issue Feb 15, 2021 · 12 comments 路 Fixed by pylint-dev/astroid#916 or PennyDreadfulMTG/Penny-Dreadful-Tools#8447
Assignees
Labels
Blocker 馃檯 Blocks the next release Crash 馃挜 A bug that makes pylint crash Regression
Milestone

Comments

@Toilal
Copy link

Toilal commented Feb 15, 2021

Steps to reproduce

  1. git clone https://github.com/inetum-orleans/docker-devbox-ddb
  2. cd docker-devbox-ddb
  3. pylint ddb
  4. 馃挜

Current behavior

Pylint crash with the following stack

Traceback (most recent call last):
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/decorators.py", line 34, in cached
    return cache[func]
KeyError: <bound method ClassDef.slots of <ClassDef.OrderedSet l.55 at 0x7f75735663d0>>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/toilal/.pyenv/versions/3.8.7-ddb/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/pylint/__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/pylint/lint/run.py", line 349, in __init__
    linter.check(args)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 862, in check
    self._check_files(
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 896, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 922, in _check_file
    check_astroid_module(ast_node)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1054, in check_astroid_module
    retval = self._check_astroid_module(
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1099, in _check_astroid_module
    walker.walk(ast_node)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 72, in walk
    callback(astroid)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/pylint/checkers/variables.py", line 1203, in visit_importfrom
    module = node.do_import_module(name_parts[0])
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/mixins.py", line 99, in do_import_module
    return mymodule.import_module(
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/scoped_nodes.py", line 646, in import_module
    return MANAGER.ast_from_module_name(absmodname)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/manager.py", line 191, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/manager.py", line 100, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/builder.py", line 139, in file_build
    return self._post_build(module, encoding)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/builder.py", line 159, in _post_build
    self.delayed_assattr(delayed)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/builder.py", line 235, in delayed_assattr
    if not _can_assign_attr(inferred, node.attrname):
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/builder.py", line 60, in _can_assign_attr
    slots = node.slots()
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/decorators.py", line 36, in cached
    cache[func] = result = func(*args, **kwargs)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/scoped_nodes.py", line 2838, in slots
    slots = list(grouped_slots())
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/scoped_nodes.py", line 2823, in grouped_slots
    for cls in self.mro()[:-1]:
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/scoped_nodes.py", line 2909, in mro
    return self._compute_mro(context=context)
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/scoped_nodes.py", line 2898, in _compute_mro
    unmerged_mro = list(clean_duplicates_mro(unmerged_mro, self, context))
  File "/home/toilal/.pyenv/versions/3.8.7/envs/3.8.7-ddb/lib/python3.8/site-packages/astroid/scoped_nodes.py", line 110, in clean_duplicates_mro
    raise exceptions.DuplicateBasesError(
astroid.exceptions.DuplicateBasesError: Duplicates found in MROs (OrderedSet), (_GenericAlias, _Final, object), (_GenericAlias, _Final, object), (_GenericAlias, _GenericAlias) for <ClassDef.OrderedSet l.55 at 0x7f75735663d0>.

Expected behavior

It should lint as usual.

pylint --version output

pylint 2.6.0
astroid 2.5
Python 3.8.7 (default, Jan 19 2021, 12:16:28) 
[GCC 9.3.0]

Problem occurs after upgrading astroid to 2.5. pip install "astroid<2.5" to workaround the issue.

@Pierre-Sassoulas
Copy link
Member

@hippo91 maybe pylint 2.6.0 needs to specify astroid < 2.5 ? If that's the case we could release 2.6.1with just a dependency change.

@cdce8p
Copy link
Member

cdce8p commented Feb 15, 2021

Hmm, I can't seem to reproduce it. I wanted to check if the error also occurs with the current pylint master branch and astroid 2.5, but it even ran without issues the first time. Here is what I did

git clone git@github.com:inetum-orleans/docker-devbox-ddb.git
# develop branch, last commit: bcf04b523482de438742e51d47198464d00f0553

cd docker-devbox-ddb.git
python3.8 -m venv venv
source venv/bin/activate
pip install pylint
pylint ddb
pylint 2.6.0
astroid 2.5
Python 3.8.7 (v3.8.7:6503f05dd5, Dec 21 2020, 12:45:15) 
[Clang 6.0 (clang-600.0.57)]
--
macOS Catalina (10.15.7)

--

@Toilal Could you provide more details (operating system, the exact commit you tested, any other useful information)? Would be great if you could also try the current master branch.

# In a new environment, run
pip install -U git+git://github.com/PyCQA/pylint.git@e48946f0b4bd385fcd93b6ef920d092f0d8d7424

If that works, we would know that the pining the astroid version as @Pierre-Sassoulas suggested would be enough to fix it.

@Toilal
Copy link
Author

Toilal commented Feb 16, 2021

I have tried current master branch, problem still occurs.

@Toilal
Copy link
Author

Toilal commented Feb 16, 2021

Also, it works properly with pylint master and astroid<2.5

@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.6.1 milestone Feb 16, 2021
@Pierre-Sassoulas Pierre-Sassoulas self-assigned this Feb 16, 2021
@Pierre-Sassoulas
Copy link
Member

Should be fixed in 2.6.1, I just released. We had astroid>=2.4.0,<=2.5, it should have been astroid>=2.4.0,<2.5.

@Pierre-Sassoulas
Copy link
Member

Thank you @Toilal for reporting the issue so fast!

@fdosani
Copy link

fdosani commented Feb 19, 2021

Hi there, Sorry to bring to life a closed issue here but felt it was better than opening a new issue. I sort of stumbled here looking through the commits and I'm getting the following error RecursionError: maximum recursion depth exceeded while calling a Python object. It seems due to the change which sets astroid < 2.5. If I force my env to bump up to 2.5 it works fine without issue. Happy to open an new issue for this but though I'd checkin and see if astroid wasn't going to be bumped back in the next release?

@hippo91
Copy link
Contributor

hippo91 commented Feb 21, 2021

@fdosani thanks for the report.
The future pylint version (coming soon) will use astroid 2.5, thus your problem will be fixed.
If you wan, you can try astroid 2.5聽with the current pylint master.

@hippo91
Copy link
Contributor

hippo91 commented Feb 21, 2021

@tollal thanks for the report. I can reproduce it.
I found the faulty commit (7f1d5134d89aab9b3e49030676637debfd731dbb). I opened a dedicated issue in astroid : pylint-dev/astroid#905

@Toilal
Copy link
Author

Toilal commented Feb 23, 2021

This stills occurs in pylint 2.7. I currently have to add those constraints as a workaround.

    "astroid<2.5",
    "pylint<2.7",

@cdce8p
Copy link
Member

cdce8p commented Feb 28, 2021

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

@Toilal
Copy link
Author

Toilal commented Mar 1, 2021

It works, thanks.

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 Regression
Projects
None yet
5 participants