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

Update Pylint to 2.5.3 #224

Merged
merged 2 commits into from
Jul 7, 2020
Merged

Update Pylint to 2.5.3 #224

merged 2 commits into from
Jul 7, 2020

Conversation

jiasli
Copy link
Member

@jiasli jiasli commented Jul 7, 2020

Same as microsoft/knack#216

CI was broken due to a breaking change in isort PyCQA/isort#1273:

py36 run-test: commands[2] | pylint knack --rcfile=.pylintrc -r n -d I0013
Traceback (most recent call last):
  File "/home/vsts/work/1/s/.tox/py36/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/vsts/work/1/s/.tox/py36/lib/python3.6/site-packages/pylint/__init__.py", line 20, in run_pylint
    Run(sys.argv[1:])
  File "/home/vsts/work/1/s/.tox/py36/lib/python3.6/site-packages/pylint/lint.py", line 1628, in __init__
    linter.check(args)
  File "/home/vsts/work/1/s/.tox/py36/lib/python3.6/site-packages/pylint/lint.py", line 943, in check
    self._do_check(files_or_modules)
  File "/home/vsts/work/1/s/.tox/py36/lib/python3.6/site-packages/pylint/lint.py", line 1075, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/home/vsts/work/1/s/.tox/py36/lib/python3.6/site-packages/pylint/lint.py", line 1158, in check_astroid_module
    walker.walk(ast_node)
  File "/home/vsts/work/1/s/.tox/py36/lib/python3.6/site-packages/pylint/utils.py", line 1305, in walk
    cb(astroid)
  File "/home/vsts/work/1/s/.tox/py36/lib/python3.6/site-packages/pylint/checkers/imports.py", line 507, in leave_module
    std_imports, ext_imports, loc_imports = self._check_imports_order(node)
  File "/home/vsts/work/1/s/.tox/py36/lib/python3.6/site-packages/pylint/checkers/imports.py", line 664, in _check_imports_order
    isort_obj = isort.SortImports(
AttributeError: module 'isort' has no attribute 'SortImports'
ERROR: InvocationError for command /home/vsts/work/1/s/.tox/py36/bin/pylint knack --rcfile=.pylintrc -r n -d I0013 (exited with code 1)

Pylint has pinned the version of isort in pylint-dev/pylint#2773, so updating Pylint so that isort is pinned (pylint-dev/pylint#2773).

wrong-import-order is disabled due to pylint-dev/pylint#2175, pylint-dev/pylint#1797

Otherwise will get error:

> pylint azdev --rcfile=.pylintrc -r n
************* Module azdev.operations.help
azdev\operations\help\__init__.py:20:0: C0411: third party import "from azure.cli.core.extension.operations import list_available_extensions, list_extensions as list_cli_extensions" should be placed before "from knack.util import CLIError" (wrong-import-order)
************* Module azdev.operations.help.refdoc.extension_docs.helpgen
azdev\operations\help\refdoc\extension_docs\helpgen.py:9:0: C0411: third party import "from azure.cli.core.file_util import _store_parsers, _is_group" should be placed before "from knack.log import get_logger" (wrong-import-order)
azdev\operations\help\refdoc\extension_docs\helpgen.py:10:0: C0411: third party import "from azure.cli.core.commands import ExtensionCommandSource" should be placed before "from knack.log import get_logger" (wrong-import-order)
azdev\operations\help\refdoc\extension_docs\helpgen.py:11:0: C0411: third party import "from azure.cli.core._help import CliCommandHelpFile" should be placed before "from knack.log import get_logger" (wrong-import-order)

This is because knack is installed by pip install --editable from source code, and is treated as a first-party lib by pylint. However, no idea why azure.cli.core is treated as a third-party library even though it is also installed from source code.

@jiasli jiasli requested a review from haroldrandom July 7, 2020 09:20
useless-suppression
useless-suppression,
import-outside-toplevel,
wrong-import-order
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which part of code cause wrong-import-order?

Copy link
Member Author

@jiasli jiasli Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right in the PR description. ⬆

For import-outside-toplevel:

py38 run-test: commands[2] | pylint azdev --rcfile=.pylintrc -r n
************* Module azdev.__main__
azdev\__main__.py:19:8: C0415: Import outside toplevel (.__VERSION__) (import-outside-toplevel)
azdev\__main__.py:25:8: C0415: Import outside toplevel (azdev.commands.load_command_table) (import-outside-toplevel)
azdev\__main__.py:31:8: C0415: Import outside toplevel (azdev.params.load_arguments) (import-outside-toplevel)
************* Module azdev.operations.code_gen
azdev\operations\code_gen.py:92:4: C0415: Import outside toplevel (tempfile) (import-outside-toplevel)
azdev\operations\code_gen.py:93:4: C0415: Import outside toplevel (zipfile) (import-outside-toplevel)
azdev\operations\code_gen.py:126:4: C0415: Import outside toplevel (shutil) (import-outside-toplevel)
azdev\operations\code_gen.py:183:4: C0415: Import outside toplevel (jinja2.Environment, jinja2.PackageLoader) (import-outside-toplevel)
************* Module azdev.operations.performance
azdev\operations\performance.py:172:4: C0415: Import outside toplevel (multiprocessing) (import-outside-toplevel)
azdev\operations\performance.py:209:4: C0415: Import outside toplevel (signal) (import-outside-toplevel)
azdev\operations\performance.py:221:4: C0415: Import outside toplevel (math.sqrt) (import-outside-toplevel)
************* Module azdev.operations.pypi
azdev\operations\pypi.py:131:4: C0415: Import outside toplevel (tempfile) (import-outside-toplevel)
azdev\operations\pypi.py:132:4: C0415: Import outside toplevel (shutil) (import-outside-toplevel)
azdev\operations\pypi.py:199:4: C0415: Import outside toplevel (zipfile) (import-outside-toplevel)
azdev\operations\pypi.py:280:4: C0415: Import outside toplevel (difflib) (import-outside-toplevel)
azdev\operations\pypi.py:297:4: C0415: Import outside toplevel (filecmp) (import-outside-toplevel)
************* Module azdev.operations.resource
azdev\operations\resource.py:28:4: C0415: Import outside toplevel (datetime.datetime, datetime.timedelta) (import-outside-toplevel)
************* Module azdev.operations.setup
azdev\operations\setup.py:133:8: C0415: Import outside toplevel (platform) (import-outside-toplevel)
azdev\operations\setup.py:146:4: C0415: Import outside toplevel (glob.glob) (import-outside-toplevel)
azdev\operations\setup.py:147:4: C0415: Import outside toplevel (importlib.import_module) (import-outside-toplevel)
azdev\operations\setup.py:163:4: C0415: Import outside toplevel (knack.prompting.prompt_y_n, knack.prompting.prompt) (import-outside-toplevel)
************* Module azdev.operations.extensions.util
azdev\operations\extensions\util.py:72:4: C0415: Import outside toplevel (requests) (import-outside-toplevel)
************* Module azdev.operations.extensions
azdev\operations\extensions\__init__.py:84:4: C0415: Import outside toplevel (glob.glob) (import-outside-toplevel)
azdev\operations\extensions\__init__.py:105:4: C0415: Import outside toplevel (glob.glob) (import-outside-toplevel)
azdev\operations\extensions\__init__.py:138:4: C0415: Import outside toplevel (hashlib) (import-outside-toplevel)
azdev\operations\extensions\__init__.py:147:4: C0415: Import outside toplevel (azdev.operations.setup._check_repo) (import-outside-toplevel)
azdev\operations\extensions\__init__.py:187:4: C0415: Import outside toplevel (re) (import-outside-toplevel)
azdev\operations\extensions\__init__.py:188:4: C0415: Import outside toplevel (tempfile) (import-outside-toplevel)
azdev\operations\extensions\__init__.py:190:4: C0415: Import outside toplevel (util.get_ext_metadata, util.get_whl_from_url) (import-outside-toplevel)
azdev\operations\extensions\__init__.py:275:4: C0415: Import outside toplevel (azure.storage.blob.BlockBlobService) (import-outside-toplevel)
************* Module azdev.operations.help
azdev\operations\help\__init__.py:304:4: C0415: Import outside toplevel (requests) (import-outside-toplevel)
************* Module azdev.operations.linter.linter
azdev\operations\linter\linter.py:157:8: C0415: Import outside toplevel (knack.deprecation.Deprecated) (import-outside-toplevel)
azdev\operations\linter\linter.py:278:8: C0415: Import outside toplevel (colorama.Fore) (import-outside-toplevel)
************* Module azdev.operations.linter.util
azdev\operations\linter\util.py:89:4: C0415: Import outside toplevel (azure.cli.core.commands.ExtensionCommandSource) (import-outside-toplevel)
************* Module azdev.operations.linter
azdev\operations\linter\__init__.py:34:4: C0415: Import outside toplevel (azure.cli.core.get_default_cli) (import-outside-toplevel)
azdev\operations\linter\__init__.py:35:4: C0415: Import outside toplevel (azure.cli.core.file_util.get_all_help, azure.cli.core.file_util.create_invoker_and_load_cmds_and_args) (import-outside-toplevel)
************* Module azdev.operations.tests
azdev\operations\tests\__init__.py:122:4: C0415: Import outside toplevel (azdev.utilities.diff_branches, azdev.utilities.extract_module_name) (import-outside-toplevel)
azdev\operations\tests\__init__.py:123:4: C0415: Import outside toplevel (azdev.utilities.git_util.summarize_changed_mods) (import-outside-toplevel)
azdev\operations\tests\__init__.py:266:8: C0415: Import outside toplevel (azdev.utilities.extract_module_name) (import-outside-toplevel)
************* Module azdev.utilities.command
azdev\utilities\command.py:24:4: C0415: Import outside toplevel (azdev.utilities.IS_WINDOWS) (import-outside-toplevel)
azdev\utilities\command.py:40:4: C0415: Import outside toplevel (azdev.utilities.IS_WINDOWS, azdev.utilities.display) (import-outside-toplevel)
azdev\utilities\command.py:70:4: C0415: Import outside toplevel (azdev.utilities.get_env_path) (import-outside-toplevel)
************* Module azdev.utilities.config
azdev\utilities\config.py:22:4: C0415: Import outside toplevel (azdev.utilities.get_env_path) (import-outside-toplevel)
************* Module azdev.utilities.git_util
azdev\utilities\git_util.py:47:4: C0415: Import outside toplevel (azdev.utilities.extract_module_name) (import-outside-toplevel)
azdev\utilities\git_util.py:64:8: C0415: Import outside toplevel (git) (import-outside-toplevel)
azdev\utilities\git_util.py:65:8: C0415: Import outside toplevel (git.exc) (import-outside-toplevel)
azdev\utilities\git_util.py:66:8: C0415: Import outside toplevel (gitdb) (import-outside-toplevel)
azdev\utilities\git_util.py:70:4: C0415: Import outside toplevel (git.Repo) (import-outside-toplevel)
************* Module azdev.utilities.path
azdev\utilities\path.py:17:4: C0415: Import outside toplevel (re) (import-outside-toplevel)
azdev\utilities\path.py:60:4: C0415: Import outside toplevel (configparser.NoSectionError) (import-outside-toplevel)
azdev\utilities\path.py:61:4: C0415: Import outside toplevel (config.get_azdev_config) (import-outside-toplevel)
azdev\utilities\path.py:73:4: C0415: Import outside toplevel (configparser.NoSectionError) (import-outside-toplevel)
azdev\utilities\path.py:74:4: C0415: Import outside toplevel (config.get_azdev_config) (import-outside-toplevel)
azdev\utilities\path.py:109:4: C0415: Import outside toplevel (errno) (import-outside-toplevel)
azdev\utilities\path.py:122:4: C0415: Import outside toplevel (azure.cli.core.extension.EXTENSIONS_DIR) (import-outside-toplevel)
azdev\utilities\path.py:193:4: C0415: Import outside toplevel (azure.cli.core.extension.EXTENSIONS_DIR) (import-outside-toplevel)
************* Module azdev.utilities.testing
azdev\utilities\testing.py:9:4: C0415: Import outside toplevel (azdev.__main__.main) (import-outside-toplevel)
azdev\utilities\testing.py:10:4: C0415: Import outside toplevel (sys) (import-outside-toplevel)
************* Module azdev.utilities.tools
azdev\utilities\tools.py:11:4: C0415: Import outside toplevel (azdev.utilities.get_env_path) (import-outside-toplevel)
azdev\utilities\tools.py:20:8: C0415: Import outside toplevel (azure.cli.core) (import-outside-toplevel)

-----------------------------------
Your code has been rated at 9.81/10

@haroldrandom haroldrandom merged commit 67e2ab2 into Azure:master Jul 7, 2020
@jiasli jiasli deleted the pylint branch July 7, 2020 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants