pylint support for Python 3.10.2

Advertisements

pylint throw an AttributeError after I updated my python from 3.6.7 to 3.10.2. It worked fine in 3.6.7.

Traceback (most recent call last):
  File "/home/yehui/Project/CleanCodeInPython/venv/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/yehui/Project/CleanCodeInPython/venv/lib/python3.10/site-packages/pylint/__init__.py", line 19, in run_pylint
    Run(sys.argv[1:])
  File "/home/yehui/Project/CleanCodeInPython/venv/lib/python3.10/site-packages/pylint/lint.py", line 1313, in __init__
    linter.load_default_plugins()
  File "/home/yehui/Project/CleanCodeInPython/venv/lib/python3.10/site-packages/pylint/lint.py", line 504, in load_default_plugins
    checkers.initialize(self)
  File "/home/yehui/Project/CleanCodeInPython/venv/lib/python3.10/site-packages/pylint/checkers/__init__.py", line 122, in initialize
    register_plugins(linter, __path__[0])
  File "/home/yehui/Project/CleanCodeInPython/venv/lib/python3.10/site-packages/pylint/utils.py", line 1181, in register_plugins
    module = modutils.load_module_from_file(join(directory, filename))
  File "/home/yehui/Project/CleanCodeInPython/venv/lib/python3.10/site-packages/astroid/modutils.py", line 258, in load_module_from_file
    return load_module_from_modpath(modpath)
  File "/home/yehui/Project/CleanCodeInPython/venv/lib/python3.10/site-packages/astroid/modutils.py", line 243, in load_module_from_modpath
    return load_module_from_name(".".join(parts))
  File "/home/yehui/Project/CleanCodeInPython/venv/lib/python3.10/site-packages/astroid/modutils.py", line 228, in load_module_from_name
    return importlib.import_module(dotted_name)
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/yehui/Project/CleanCodeInPython/venv/lib/python3.10/site-packages/pylint/checkers/imports.py", line 41, in <module>
    import isort
  File "/home/yehui/Project/CleanCodeInPython/venv/lib/python3.10/site-packages/isort/__init__.py", line 25, in <module>
    from . import settings  # noqa: F401
  File "/home/yehui/Project/CleanCodeInPython/venv/lib/python3.10/site-packages/isort/settings.py", line 34, in <module>
    from .pie_slice import itemsview, lru_cache, native_str
  File "/home/yehui/Project/CleanCodeInPython/venv/lib/python3.10/site-packages/isort/pie_slice.py", line 362, in <module>
    class OrderedSet(collections.MutableSet):
AttributeError: module 'collections' has no attribute 'MutableSet'

Anyone else got this problem? My pylint is 2.12.2

Edit: Like the answer said. I didn’t update isort after update pylint. After isort update it should be fine

>Solution :

The actual error seems to be happening in isort, would you mind upgrading the isort version ? (pip install isort -U) pylint is compatible with a wide range of isort versions. Some of those isort versions might not be compatible with python 3.10 (in this case the isort that was initially installed alongside pylint for python 3.6) when you upgrade pylint it might not upgrade isort automatically.

Leave a Reply Cancel reply