a2i2 / mining-data-science-repositories

A large-scale comparative analysis of Coding Standard conformance in Open-Source Data Science projects
https://arxiv.org/abs/2007.08978
7 stars 5 forks source link

Pylint will use repo modules on PATH rather than its own #14

Closed anjsimmo closed 4 years ago

anjsimmo commented 4 years ago

Expected Behaviour:

Actual behaviour:

Example:

INFO:root:../input/39565135
ERROR:root:['Traceback (most recent call last):', '  File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main', '    "__main__", mod_spec)', '  File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code', '    exec(code, run_globals)', '  File "/app/clean_env_py3/lib/python3.6/site-packages/pylint/__main__.py", line 7, in <module>', '    pylint.run_pylint()', '  File "/app/clean_env_py3/lib/python3.6/site-packages/pylint/__init__.py", line 23, in run_pylint', '    PylintRun(sys.argv[1:])', '  File "/app/clean_env_py3/lib/python3.6/site-packages/pylint/lint.py", line 1637, in __init__', '    linter.load_default_plugins()', '  File "/app/clean_env_py3/lib/python3.6/site-packages/pylint/lint.py", line 645, in load_default_plugins', '    checkers.initialize(self)', '  File "/app/clean_env_py3/lib/python3.6/site-packages/pylint/checkers/__init__.py", line 61, in initialize', '    register_plugins(linter, __path__[0])', '  File "/app/clean_env_py3/lib/python3.6/site-packages/pylint/utils/utils.py", line 218, in register_plugins', '    module = modutils.load_module_from_file(join(directory, filename))', '  File "/app/clean_env_py3/lib/python3.6/site-packages/astroid/modutils.py", line 280, in load_module_from_file', '    return load_module_from_modpath(modpath, path, use_sys)', '  File "/app/clean_env_py3/lib/python3.6/site-packages/astroid/modutils.py", line 241, in load_module_from_modpath', '    module = imp.load_module(curname, mp_file, mp_filename, mp_desc)', '  File "/usr/local/lib/python3.6/imp.py", line 235, in load_module', '    return load_source(name, filename, file)', '  File "/usr/local/lib/python3.6/imp.py", line 172, in load_source', '    module = _load(spec)', '  File "<frozen importlib._bootstrap>", line 684, in _load', '  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked', '  File "<frozen importlib._bootstrap_external>", line 678, in exec_module', '  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed', '  File "/app/clean_env_py3/lib/python3.6/site-packages/pylint/checkers/imports.py", line 40, in <module>', '    import isort', '  File "/app/clean_env_py3/lib/python3.6/site-packages/isort/__init__.py", line 25, in <module>', '    from . import settings  # noqa: F401', '  File "/app/clean_env_py3/lib/python3.6/site-packages/isort/settings.py", line 52, in <module>', "    if appdirs.system == 'darwin':", "AttributeError: module 'appdirs' has no attribute 'system'"]

Details:

https://github.com/PyCQA/pylint/blob/pylint-2.4.4/pylint/checkers/imports.py#L40

import isort

https://github.com/timothycrosley/isort/blob/4.3.21/isort/settings.py#L45

try:
    import appdirs
    if appdirs.system == 'darwin':
        appdirs.system = 'linux2'
except ImportError:
    appdirs = None

As appdirs package is not installed, the code is meant to catch an ImportError. Instead, it loads the local appdirs.py, which results in AttributeError: module 'appdirs' has no attribute 'system'" as it is a different module to what it expected.

anjsimmo commented 4 years ago

Additional details:

Was due to calling python -m pylint from within repo directories rather than using the pylint executable directly. This is fixed within #15.