Azure / autorest.az

Azure CLI Code Generator
MIT License
22 stars 20 forks source link

Import error in custom.py #783

Closed qwordy closed 3 years ago

qwordy commented 3 years ago

The following code is generated and inserted into existing custom.py

from .generated.custom import *  # noqa: F403
try:
    from .manual.custom import *   # noqa: F403
except ImportError:
    pass

However, it causes style errors.

************* Module azure.cli.command_modules.vm.custom
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:16:0: W0401: Wildcard import generated.custom (wildcard-import)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:16:0: W0614: Unused import sshkey_list from wildcard import (unused-wildcard-import)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:16:0: W0614: Unused import sshkey_show from wildcard import (unused-wildcard-import)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:16:0: W0614: Unused import sshkey_create from wildcard import (unused-wildcard-import)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:16:0: W0614: Unused import sshkey_update from wildcard import (unused-wildcard-import)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:16:0: W0614: Unused import sshkey_delete from wildcard import (unused-wildcard-import)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:22:0: C0411: standard import "import json" should be placed before "from .generated.custom import *" (wrong-import-order)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:23:0: C0411: standard import "import os" should be placed before "from .generated.custom import *" (wrong-import-order)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:25:0: C0411: third party import "import requests" should be placed before "from .generated.custom import *" (wrong-import-order)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:33:0: C0411: third party import "from six.moves.urllib.request import urlopen" should be placed before "from .generated.custom import *" (wrong-import-order)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:35:0: C0411: third party import "from knack.log import get_logger" should be placed before "from .generated.custom import *" (wrong-import-order)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:36:0: C0411: third party import "from knack.util import CLIError" should be placed before "from .generated.custom import *" (wrong-import-order)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:38:0: C0411: third party import "from azure.cli.command_modules.vm._validators import _get_resource_group_from_vault_name" should be placed before "from .generated.custom import *" (wrong-import-order)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:39:0: C0411: third party import "from azure.cli.core.commands.validators import validate_file_or_dict" should be placed before "from .generated.custom import *" (wrong-import-order)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:41:0: C0411: third party import "from azure.cli.core.commands import LongRunningOperation, DeploymentOutputLongRunningOperation" should be placed before "from .generated.custom import *" (wrong-import-order)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:42:0: C0411: third party import "from azure.cli.core.commands.client_factory import get_mgmt_service_client, get_data_service_client" should be placed before "from .generated.custom import *" (wrong-import-order)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:43:0: C0411: third party import "from azure.cli.core.profiles import ResourceType" should be placed before "from .generated.custom import *" (wrong-import-order)
c:\yfy\azure-cli\src\azure-cli\azure\cli\command_modules\vm\custom.py:44:0: C0411: third party import "from azure.cli.core.util import sdk_no_wait" should be placed before "from .generated.custom import *" (wrong-import-order)

It can be fixed by reordering import statement and adding

pylint: disable=unused-wildcard-import,wildcard-import
lirenhe commented 3 years ago

Fixed