From b46f3440137ead38dd7d7b8674cffd573b191768 Mon Sep 17 00:00:00 2001 From: Hang Date: Tue, 3 Dec 2024 17:03:58 +0800 Subject: [PATCH] {Pylint} Fix superfluous-parens (#30361) --- pylintrc | 1 - src/azure-cli-core/azure/cli/core/_profile.py | 2 +- .../azure/cli/core/commands/arm.py | 2 +- .../cli/core/extension/_homebrew_patch.py | 2 +- .../azure/cli/core/extension/_index.py | 2 +- .../azure/cli/core/extension/operations.py | 2 +- src/azure-cli-core/azure/cli/core/parser.py | 2 +- .../cli/command_modules/acr/_docker_utils.py | 10 +++---- .../cli/command_modules/acr/check_health.py | 4 +-- .../azure/cli/command_modules/acr/pack.py | 2 +- .../cli/command_modules/acs/_validators.py | 4 +-- .../azure/cli/command_modules/acs/custom.py | 4 +-- .../cli/command_modules/appconfig/keyvalue.py | 4 +-- .../appservice/access_restrictions.py | 4 +-- .../cli/command_modules/appservice/custom.py | 30 +++++++++---------- .../tests/latest/test_logicapp_commands.py | 6 ++-- .../tests/latest/test_webapp_commands.py | 10 +++---- .../cli/command_modules/backup/custom.py | 2 +- .../command_modules/batch/_command_type.py | 12 ++++---- .../cli/command_modules/botservice/custom.py | 4 +-- .../azure/cli/command_modules/iot/custom.py | 4 +-- .../cli/command_modules/keyvault/custom.py | 4 +-- .../azure/cli/command_modules/lab/commands.py | 2 +- .../autoscale/AutoscaleConditionParser.py | 8 ++--- .../MetricAlertConditionParser.py | 12 ++++---- .../cli/command_modules/netappfiles/custom.py | 6 ++-- .../cli/command_modules/network/custom.py | 2 +- .../rdbms/flexible_server_custom_common.py | 6 ++-- .../rdbms/flexible_server_custom_postgres.py | 2 +- .../cli/command_modules/rdbms/validators.py | 12 ++++---- .../cli/command_modules/resource/custom.py | 16 +++++----- .../azure/cli/command_modules/role/_params.py | 2 +- .../cli/command_modules/role/_validators.py | 4 +-- .../serviceconnector/commands.py | 2 +- .../azure/cli/command_modules/sql/_format.py | 2 +- .../azure/cli/command_modules/sql/custom.py | 2 +- .../storage/_transformers_azure_stack.py | 8 ++--- .../azure/cli/command_modules/util/custom.py | 2 +- .../azure/cli/command_modules/vm/_actions.py | 4 +-- .../cli/command_modules/vm/_validators.py | 6 ++-- .../vm/azure_stack/_actions.py | 4 +-- .../vm/azure_stack/_validators.py | 4 +-- .../command_modules/vm/azure_stack/custom.py | 4 +-- .../azure/cli/command_modules/vm/custom.py | 8 ++--- 44 files changed, 117 insertions(+), 118 deletions(-) diff --git a/pylintrc b/pylintrc index ea77c7e0eae..d4fe9d3113c 100644 --- a/pylintrc +++ b/pylintrc @@ -45,7 +45,6 @@ disable= consider-using-enumerate, # These rules were added in Pylint >= 2.12, disable them to avoid making retroactive change missing-timeout, - superfluous-parens, unnecessary-dunder-call, # These rules were added in Pylint >= 3.2 possibly-used-before-assignment, diff --git a/src/azure-cli-core/azure/cli/core/_profile.py b/src/azure-cli-core/azure/cli/core/_profile.py index 5fbab701539..7c09c1ac6d3 100644 --- a/src/azure-cli-core/azure/cli/core/_profile.py +++ b/src/azure-cli-core/azure/cli/core/_profile.py @@ -691,7 +691,7 @@ def refresh_accounts(self): if user_name in refreshed_list: continue refreshed_list.add(user_name) - is_service_principal = (s[_USER_ENTITY][_USER_TYPE] == _SERVICE_PRINCIPAL) + is_service_principal = s[_USER_ENTITY][_USER_TYPE] == _SERVICE_PRINCIPAL tenant = s[_TENANT_ID] subscriptions = [] try: diff --git a/src/azure-cli-core/azure/cli/core/commands/arm.py b/src/azure-cli-core/azure/cli/core/commands/arm.py index 28d1e0f5c68..90c1f897229 100644 --- a/src/azure-cli-core/azure/cli/core/commands/arm.py +++ b/src/azure-cli-core/azure/cli/core/commands/arm.py @@ -258,7 +258,7 @@ def parse_ids_arguments(_, command, args): # ensure the required parameters are provided if --ids is not errors = [arg for arg in required_args if getattr(namespace, arg.name, None) is None] if errors: - missing_required = ' '.join((arg.options_list[0] for arg in errors)) + missing_required = ' '.join(arg.options_list[0] for arg in errors) raise CLIError('({} | {}) are required'.format(missing_required, '--ids')) return diff --git a/src/azure-cli-core/azure/cli/core/extension/_homebrew_patch.py b/src/azure-cli-core/azure/cli/core/extension/_homebrew_patch.py index 7e914fa05ae..01c95c01308 100644 --- a/src/azure-cli-core/azure/cli/core/extension/_homebrew_patch.py +++ b/src/azure-cli-core/azure/cli/core/extension/_homebrew_patch.py @@ -14,7 +14,7 @@ def is_homebrew(): - return any((p.startswith(HOMEBREW_CELLAR_PATH) for p in sys.path)) + return any(p.startswith(HOMEBREW_CELLAR_PATH) for p in sys.path) # A workaround for https://github.com/Azure/azure-cli/issues/4428 diff --git a/src/azure-cli-core/azure/cli/core/extension/_index.py b/src/azure-cli-core/azure/cli/core/extension/_index.py index 4e90810768b..b2b49196213 100644 --- a/src/azure-cli-core/azure/cli/core/extension/_index.py +++ b/src/azure-cli-core/azure/cli/core/extension/_index.py @@ -44,7 +44,7 @@ def get_index(index_url=None, cli_ctx=None): for try_number in range(TRIES): try: - response = requests.get(index_url, verify=(not should_disable_connection_verify())) + response = requests.get(index_url, verify=not should_disable_connection_verify()) if response.status_code == 200: return response.json() msg = ERR_TMPL_NON_200.format(response.status_code, index_url) diff --git a/src/azure-cli-core/azure/cli/core/extension/operations.py b/src/azure-cli-core/azure/cli/core/extension/operations.py index 6f66caef4f3..29303b271f3 100644 --- a/src/azure-cli-core/azure/cli/core/extension/operations.py +++ b/src/azure-cli-core/azure/cli/core/extension/operations.py @@ -65,7 +65,7 @@ def _whl_download_from_url(url_parse_result, ext_file): import requests from azure.cli.core.util import should_disable_connection_verify url = url_parse_result.geturl() - r = requests.get(url, stream=True, verify=(not should_disable_connection_verify())) + r = requests.get(url, stream=True, verify=not should_disable_connection_verify()) if r.status_code != 200: raise CLIError("Request to {} failed with {}".format(url, r.status_code)) with open(ext_file, 'wb') as f: diff --git a/src/azure-cli-core/azure/cli/core/parser.py b/src/azure-cli-core/azure/cli/core/parser.py index 1a20b4cd8a5..0a844b8c0fa 100644 --- a/src/azure-cli-core/azure/cli/core/parser.py +++ b/src/azure-cli-core/azure/cli/core/parser.py @@ -32,7 +32,7 @@ "To learn more about extensions, please visit " "'https://docs.microsoft.com/cli/azure/azure-cli-extensions-overview'") -OVERVIEW_REFERENCE = ("https://aka.ms/cli_ref") +OVERVIEW_REFERENCE = "https://aka.ms/cli_ref" class IncorrectUsageError(CLIError): diff --git a/src/azure-cli/azure/cli/command_modules/acr/_docker_utils.py b/src/azure-cli/azure/cli/command_modules/acr/_docker_utils.py index 8fd784f039b..f3377faed6f 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/_docker_utils.py +++ b/src/azure-cli/azure/cli/command_modules/acr/_docker_utils.py @@ -100,7 +100,7 @@ def _handle_challenge_phase(login_server, request_url = 'https://' + login_server + '/v2/' logger.debug(add_timestamp("Sending a HTTP Get request to {}".format(request_url))) - challenge = requests.get(request_url, verify=(not should_disable_connection_verify())) + challenge = requests.get(request_url, verify=not should_disable_connection_verify()) if challenge.status_code != 401 or 'WWW-Authenticate' not in challenge.headers: from ._errors import CONNECTIVITY_CHALLENGE_ERROR @@ -164,7 +164,7 @@ def _get_aad_token_after_challenge(cli_ctx, logger.debug(add_timestamp("Sending a HTTP Post request to {}".format(authhost))) response = requests.post(authhost, urlencode(content), headers=headers, - verify=(not should_disable_connection_verify())) + verify=not should_disable_connection_verify()) if response.status_code == 429: if is_diagnostics_context: @@ -200,7 +200,7 @@ def _get_aad_token_after_challenge(cli_ctx, logger.debug(add_timestamp("Sending a HTTP Post request to {}".format(authhost))) response = requests.post(authhost, urlencode(content), headers=headers, - verify=(not should_disable_connection_verify())) + verify=not should_disable_connection_verify()) if response.status_code not in [200]: from ._errors import CONNECTIVITY_ACCESS_TOKEN_ERROR @@ -301,7 +301,7 @@ def _get_token_with_username_and_password(login_server, logger.debug(add_timestamp("Sending a HTTP Post request to {}".format(authhost))) response = requests.post(authhost, urlencode(content), headers=headers, - verify=(not should_disable_connection_verify())) + verify=not should_disable_connection_verify()) if response.status_code != 200: from ._errors import CONNECTIVITY_ACCESS_TOKEN_ERROR @@ -365,7 +365,7 @@ def _get_credentials(cmd, # pylint: disable=too-many-statements url = 'https://' + login_server + '/v2/' try: logger.debug(add_timestamp("Sending a HTTP Get request to {}".format(url))) - challenge = requests.get(url, verify=(not should_disable_connection_verify())) + challenge = requests.get(url, verify=not should_disable_connection_verify()) if challenge.status_code == 403: raise CLIError("Looks like you don't have access to registry '{}'. " "To see configured firewall rules, run 'az acr show --query networkRuleSet --name {}'. " diff --git a/src/azure-cli/azure/cli/command_modules/acr/check_health.py b/src/azure-cli/azure/cli/command_modules/acr/check_health.py index 12748af1c4f..13efdf9122e 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/check_health.py +++ b/src/azure-cli/azure/cli/command_modules/acr/check_health.py @@ -234,7 +234,7 @@ def _get_registry_status(login_server, registry_name, ignore_errors): try: request_url = 'https://' + login_server + '/v2/' logger.debug(add_timestamp("Sending a HTTP GET request to {}".format(request_url))) - challenge = requests.get(request_url, verify=(not should_disable_connection_verify())) + challenge = requests.get(request_url, verify=not should_disable_connection_verify()) except SSLError: from ._errors import CONNECTIVITY_SSL_ERROR _handle_error(CONNECTIVITY_SSL_ERROR.format_error_message(login_server), ignore_errors) @@ -334,7 +334,7 @@ def _check_registry_health(cmd, registry_name, ignore_errors): if v.client_id == client_id: from azure.core.exceptions import HttpResponseError try: - valid_identity = (resolve_identity_client_id(cmd.cli_ctx, k) == client_id) + valid_identity = resolve_identity_client_id(cmd.cli_ctx, k) == client_id except HttpResponseError: pass if not valid_identity: diff --git a/src/azure-cli/azure/cli/command_modules/acr/pack.py b/src/azure-cli/azure/cli/command_modules/acr/pack.py index d30ff81c7c9..f244655887b 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/pack.py +++ b/src/azure-cli/azure/cli/command_modules/acr/pack.py @@ -63,7 +63,7 @@ def acr_pack_build(cmd, # pylint: disable=too-many-locals registry_prefixes = '$Registry/', registry.login_server + '/' # If the image name doesn't have any required prefix, add it - if all((not image_name.startswith(prefix) for prefix in registry_prefixes)): + if all(not image_name.startswith(prefix) for prefix in registry_prefixes): original_image_name = image_name image_name = registry_prefixes[0] + image_name logger.debug('Modified image name from %s to %s', original_image_name, image_name) diff --git a/src/azure-cli/azure/cli/command_modules/acs/_validators.py b/src/azure-cli/azure/cli/command_modules/acs/_validators.py index a12aafe25f1..5a2f0db8ca4 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_validators.py @@ -82,8 +82,8 @@ def validate_ip_ranges(namespace): ip_ranges = [ip.strip() for ip in namespace.api_server_authorized_ip_ranges.split(",")] if restrict_traffic_to_agentnodes in ip_ranges and len(ip_ranges) > 1: - raise CLIError(("Setting --api-server-authorized-ip-ranges to 0.0.0.0/32 is not allowed with other IP ranges." - "Refer to https://aka.ms/aks/whitelist for more details")) + raise CLIError("Setting --api-server-authorized-ip-ranges to 0.0.0.0/32 is not allowed with other IP ranges." + "Refer to https://aka.ms/aks/whitelist for more details") if allow_all_traffic in ip_ranges and len(ip_ranges) > 1: raise CLIError("--api-server-authorized-ip-ranges cannot be disabled and simultaneously enabled") diff --git a/src/azure-cli/azure/cli/command_modules/acs/custom.py b/src/azure-cli/azure/cli/command_modules/acs/custom.py index 365f84e524d..45b6bc75e42 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/custom.py @@ -241,7 +241,7 @@ def _aks_browse( stderr=subprocess.STDOUT, ) # output format: "'{port}'" - dashboard_port = int((dashboard_port.replace("'", ""))) + dashboard_port = int(dashboard_port.replace("'", "")) except subprocess.CalledProcessError as err: raise ResourceNotFoundError('Could not find dashboard port: {} Command output: {}'.format(err, err.output)) @@ -473,7 +473,7 @@ def wait_then_open_async(url): """ Spawns a thread that waits for a bit then opens a URL. """ - t = threading.Thread(target=wait_then_open, args=({url})) + t = threading.Thread(target=wait_then_open, args=(url,)) t.daemon = True t.start() diff --git a/src/azure-cli/azure/cli/command_modules/appconfig/keyvalue.py b/src/azure-cli/azure/cli/command_modules/appconfig/keyvalue.py index ac51e396b97..832712cbd45 100644 --- a/src/azure-cli/azure/cli/command_modules/appconfig/keyvalue.py +++ b/src/azure-cli/azure/cli/command_modules/appconfig/keyvalue.py @@ -225,8 +225,8 @@ def import_config(cmd, kvs_to_write = [] kvs_to_write.extend(kv_diff.get(JsonDiff.ADD, [])) kvs_to_write.extend(ff_diff.get(JsonDiff.ADD, [])) - kvs_to_write.extend((update["new"] for update in kv_diff.get(JsonDiff.UPDATE, []))) - kvs_to_write.extend((update["new"] for update in ff_diff.get(JsonDiff.UPDATE, []))) + kvs_to_write.extend(update["new"] for update in kv_diff.get(JsonDiff.UPDATE, [])) + kvs_to_write.extend(update["new"] for update in ff_diff.get(JsonDiff.UPDATE, [])) # write all kvs else: diff --git a/src/azure-cli/azure/cli/command_modules/appservice/access_restrictions.py b/src/azure-cli/azure/cli/command_modules/appservice/access_restrictions.py index 378dc166523..e8e27b341f0 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/access_restrictions.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/access_restrictions.py @@ -47,7 +47,7 @@ def add_webapp_access_restriction( int(subnet is not None) != 1): err_msg = 'Please specify either: --subnet or --ip-address or --service-tag' raise MutuallyExclusiveArgumentError(err_msg) - if (skip_service_tag_validation is not None): + if skip_service_tag_validation is not None: logger.warning('Skipping service tag validation.') # get rules list @@ -98,7 +98,7 @@ def remove_webapp_access_restriction(cmd, resource_group_name, name, rule_name=N if input_rule_types > 1: err_msg = 'Please specify either: --subnet or --ip-address or --service-tag' raise MutuallyExclusiveArgumentError(err_msg) - if (skip_service_tag_validation is not None): + if skip_service_tag_validation is not None: logger.warning('Skipping service tag validation.') rule_instance = None diff --git a/src/azure-cli/azure/cli/command_modules/appservice/custom.py b/src/azure-cli/azure/cli/command_modules/appservice/custom.py index 67918e22a43..97c9e472bab 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/custom.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/custom.py @@ -475,7 +475,7 @@ def check_language_runtime(cmd, resource_group_name, name): functions_version = runtime_info['functionapp_version'] if runtime and runtime_version: if not is_flex: - runtime_helper = _FunctionAppStackRuntimeHelper(cmd=cmd, linux=is_linux, windows=(not is_linux)) + runtime_helper = _FunctionAppStackRuntimeHelper(cmd=cmd, linux=is_linux, windows=not is_linux) runtime_helper.resolve(runtime, runtime_version, functions_version, is_linux) else: location = app.location @@ -929,9 +929,9 @@ def validate_zip_deploy_app_setting_exists(cmd, resource_group_name, name, slot= storage_connection = str(keyval['value']) if storage_connection is None: - raise ValidationError(('The Azure CLI does not support this deployment path. Please ' - 'configure the app to deploy from a remote package using the steps here: ' - 'https://aka.ms/deployfromurl')) + raise ValidationError('The Azure CLI does not support this deployment path. Please ' + 'configure the app to deploy from a remote package using the steps here: ' + 'https://aka.ms/deployfromurl') def upload_zip_to_storage(cmd, resource_group_name, name, src, slot=None): @@ -4239,7 +4239,7 @@ def _parse_raw_stacks(self, stacks): for major_version in runtime['properties']['majorVersions']: for minor_version in major_version['minorVersions']: runtime_version = minor_version['value'] - if (minor_version['stackSettings'].get('linuxRuntimeSettings') is None): + if minor_version['stackSettings'].get('linuxRuntimeSettings') is None: continue runtime_settings = minor_version['stackSettings']['linuxRuntimeSettings'] @@ -4791,7 +4791,7 @@ def create_functionapp(cmd, resource_group_name, name, storage_account, plan=Non if functions_version is None and flexconsumption_location is None: logger.warning("No functions version specified so defaulting to 4.") functions_version = '4' - enable_dapr = (enable_dapr == "true") + enable_dapr = enable_dapr == "true" if deployment_source_url and deployment_local_git: raise MutuallyExclusiveArgumentError('usage error: --deployment-source-url | --deployment-local-git') if any([cpu, memory, workload_profile_name]) and environment is None: @@ -4875,7 +4875,7 @@ def create_functionapp(cmd, resource_group_name, name, storage_account, plan=Non if flexconsumption_location is None: deployment_source_branch = deployment_source_branch or 'master' - disable_app_insights = (disable_app_insights == "true") + disable_app_insights = disable_app_insights == "true" site_config = SiteConfig(app_settings=[]) client = web_client_factory(cmd.cli_ctx) @@ -4992,7 +4992,7 @@ def create_functionapp(cmd, resource_group_name, name, storage_account, plan=Non runtime_helper = _FlexFunctionAppStackRuntimeHelper(cmd, flexconsumption_location, runtime, runtime_version) matched_runtime = runtime_helper.resolve(runtime, runtime_version) else: - runtime_helper = _FunctionAppStackRuntimeHelper(cmd, linux=is_linux, windows=(not is_linux)) + runtime_helper = _FunctionAppStackRuntimeHelper(cmd, linux=is_linux, windows=not is_linux) matched_runtime = runtime_helper.resolve("dotnet" if not runtime else runtime, runtime_version, functions_version, is_linux) @@ -5082,10 +5082,10 @@ def create_functionapp(cmd, resource_group_name, name, storage_account, plan=Non # validate cpu and memory parameters. _validate_cpu_momory_functionapp(cpu, memory) - if (workload_profile_name is not None): + if workload_profile_name is not None: functionapp_def.workload_profile_name = workload_profile_name - if (cpu is not None and memory is not None): + if cpu is not None and memory is not None: functionapp_def.resource_config = ResourceConfig() functionapp_def.resource_config.cpu = cpu functionapp_def.resource_config.memory = memory @@ -5105,7 +5105,7 @@ def create_functionapp(cmd, resource_group_name, name, storage_account, plan=Non if enable_dapr: logger.warning("Please note while using Dapr Extension for Azure Functions, app port is " "mandatory when using Dapr triggers and should be empty when using only Dapr bindings.") - dapr_enable_api_logging = (dapr_enable_api_logging == "true") + dapr_enable_api_logging = dapr_enable_api_logging == "true" dapr_config = DaprConfig() dapr_config.enabled = True dapr_config.app_id = dapr_app_id @@ -8187,7 +8187,7 @@ def _remove_publish_profile_from_github(cmd, resource_group, name, repo, token, def _runtime_supports_github_actions(cmd, runtime_string, is_linux): - helper = _StackRuntimeHelper(cmd, linux=(is_linux), windows=(not is_linux)) + helper = _StackRuntimeHelper(cmd, linux=is_linux, windows=not is_linux) matched_runtime = helper.resolve(runtime_string, is_linux) if not matched_runtime: return False @@ -8203,8 +8203,8 @@ def _get_functionapp_runtime_version(cmd, location, name, resource_group, runtim is_flex = is_flex_functionapp(cmd.cli_ctx, resource_group, name) try: - if (not is_flex): - helper = _FunctionAppStackRuntimeHelper(cmd, linux=(is_linux), windows=(not is_linux)) + if not is_flex: + helper = _FunctionAppStackRuntimeHelper(cmd, linux=is_linux, windows=not is_linux) matched_runtime = helper.resolve(runtime_string, runtime_version, functionapp_version, is_linux) else: runtime_helper = _FlexFunctionAppStackRuntimeHelper(cmd, location, runtime_string, runtime_version) @@ -8328,7 +8328,7 @@ def _get_functionapp_runtime_info(cmd, resource_group, name, slot, is_linux): # def _get_app_runtime_info_helper(cmd, app_runtime, app_runtime_version, is_linux): - helper = _StackRuntimeHelper(cmd, linux=(is_linux), windows=(not is_linux)) + helper = _StackRuntimeHelper(cmd, linux=is_linux, windows=not is_linux) if not is_linux: matched_runtime = helper.resolve("{}|{}".format(app_runtime, app_runtime_version), is_linux) else: diff --git a/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_logicapp_commands.py b/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_logicapp_commands.py index 23645a7f2b7..3e09d679847 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_logicapp_commands.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_logicapp_commands.py @@ -134,10 +134,10 @@ def test_logicapp_e2etest_logicapp_versions_e2e(self, resource_group, storage_ac # show result = self.cmd('logicapp config appsettings list -g {} -n {}'.format( resource_group, logicapp_name)).get_output_in_json() - appsetting_runtime_version = next((x for x in result if x['name'] == 'WEBSITE_NODE_DEFAULT_VERSION')) + appsetting_runtime_version = next(x for x in result if x['name'] == 'WEBSITE_NODE_DEFAULT_VERSION') self.assertEqual(appsetting_runtime_version['name'], 'WEBSITE_NODE_DEFAULT_VERSION') self.assertEqual(appsetting_runtime_version['value'], '~16') - appsetting_functions_version = next((x for x in result if x['name'] == 'FUNCTIONS_EXTENSION_VERSION')) + appsetting_functions_version = next(x for x in result if x['name'] == 'FUNCTIONS_EXTENSION_VERSION') self.assertEqual(appsetting_functions_version['name'], 'FUNCTIONS_EXTENSION_VERSION') self.assertEqual(appsetting_functions_version['value'], '~4') @@ -179,7 +179,7 @@ def test_logicapp_config_appsettings_e2e(self, resource_group): # show result = self.cmd('logicapp config appsettings list -g {} -n {}'.format( resource_group, logicapp_name)).get_output_in_json() - s2 = next((x for x in result if x['name'] == 's2')) + s2 = next(x for x in result if x['name'] == 's2') self.assertEqual(s2['name'], 's2') self.assertEqual(s2['slotSetting'], False) self.assertEqual(s2['value'], 'bar') diff --git a/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands.py b/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands.py index 5ee73cce36a..c615cc894d6 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands.py @@ -695,7 +695,7 @@ def test_webapp_config(self, resource_group): # show result = self.cmd('webapp config appsettings list -g {} -n {}'.format( resource_group, webapp_name)).get_output_in_json() - s2 = next((x for x in result if x['name'] == 's2')) + s2 = next(x for x in result if x['name'] == 's2') self.assertEqual(s2['name'], 's2') self.assertEqual(s2['slotSetting'], False) self.assertEqual(s2['value'], 'bar') @@ -916,7 +916,7 @@ def test_webapp_config_appsettings(self, resource_group): # show result = self.cmd('webapp config appsettings list -g {} -n {}'.format( resource_group, webapp_name)).get_output_in_json() - s2 = next((x for x in result if x['name'] == 's2')) + s2 = next(x for x in result if x['name'] == 's2') self.assertEqual(s2['name'], 's2') self.assertEqual(s2['slotSetting'], False) self.assertEqual(s2['value'], 'bar') @@ -1218,11 +1218,11 @@ def test_linux_webapp(self, resource_group): self.assertEqual(set(x['value'] for x in result if x['name'] == 'DOCKER_REGISTRY_SERVER_PASSWORD'), set([None])) # we mask the password sample = next( - (x for x in result if x['name'] == 'DOCKER_REGISTRY_SERVER_URL')) + x for x in result if x['name'] == 'DOCKER_REGISTRY_SERVER_URL') self.assertEqual(sample, { 'name': 'DOCKER_REGISTRY_SERVER_URL', 'slotSetting': False, 'value': 'foo-url'}) sample = next( - (x for x in result if x['name'] == 'WEBSITES_ENABLE_APP_SERVICE_STORAGE')) + x for x in result if x['name'] == 'WEBSITES_ENABLE_APP_SERVICE_STORAGE') self.assertEqual(sample, { 'name': 'WEBSITES_ENABLE_APP_SERVICE_STORAGE', 'slotSetting': False, 'value': 'false'}) @@ -1231,7 +1231,7 @@ def test_linux_webapp(self, resource_group): self.assertEqual(set(x['value'] for x in result if x['name'] == 'DOCKER_REGISTRY_SERVER_PASSWORD'), set([None])) # we mask the password sample = next( - (x for x in result if x['name'] == 'WEBSITES_ENABLE_APP_SERVICE_STORAGE')) + x for x in result if x['name'] == 'WEBSITES_ENABLE_APP_SERVICE_STORAGE') self.assertEqual(sample, { 'name': 'WEBSITES_ENABLE_APP_SERVICE_STORAGE', 'slotSetting': False, 'value': 'true'}) diff --git a/src/azure-cli/azure/cli/command_modules/backup/custom.py b/src/azure-cli/azure/cli/command_modules/backup/custom.py index 66830a3df78..93389fc0c79 100644 --- a/src/azure-cli/azure/cli/command_modules/backup/custom.py +++ b/src/azure-cli/azure/cli/command_modules/backup/custom.py @@ -1074,7 +1074,7 @@ def update_policy_for_item(cmd, client, resource_group_name, vault_name, item, p if not prompt_y_n(warning_prompt): logger.warning('Cancelling policy update operation') return None - except (AttributeError): + except AttributeError: logger.warning("Unable to fetch policy type for either existing or new policy. Proceeding with update.") # Update policy diff --git a/src/azure-cli/azure/cli/command_modules/batch/_command_type.py b/src/azure-cli/azure/cli/command_modules/batch/_command_type.py index fbb31f3b2b1..c48fe52093c 100644 --- a/src/azure-cli/azure/cli/command_modules/batch/_command_type.py +++ b/src/azure-cli/azure/cli/command_modules/batch/_command_type.py @@ -748,12 +748,12 @@ def _load_transformed_arguments(self, handler): choices = docstring[values_index + 25:].split(', ') choices = [enum_value(c) for c in choices if enum_value(c) != "'unmapped'"] docstring = docstring[0:values_index] - args.append(((arg[0], CLICommandArgument(arg[0], - options_list=[arg_name(arg[0])], - required=False, - default=None, - choices=choices, - help=docstring)))) + args.append((arg[0], CLICommandArgument(arg[0], + options_list=[arg_name(arg[0])], + required=False, + default=None, + choices=choices, + help=docstring))) elif arg_type.startswith("~"): # TODO: could add handling for enums param_type = class_name(arg_type) self.parser.set_request_param(arg[0], param_type) diff --git a/src/azure-cli/azure/cli/command_modules/botservice/custom.py b/src/azure-cli/azure/cli/command_modules/botservice/custom.py index c9494b414a9..c8c39be310f 100644 --- a/src/azure-cli/azure/cli/command_modules/botservice/custom.py +++ b/src/azure-cli/azure/cli/command_modules/botservice/custom.py @@ -360,8 +360,8 @@ def get_service_providers(client, name=None): name = name and name.lower() if name: try: - return next((item for item in service_provider_response.value if - item.properties.service_provider_name.lower() == name.lower())) + return next(item for item in service_provider_response.value if + item.properties.service_provider_name.lower() == name.lower()) except StopIteration: raise CLIError('A service provider with the name {0} was not found'.format(name)) return service_provider_response diff --git a/src/azure-cli/azure/cli/command_modules/iot/custom.py b/src/azure-cli/azure/cli/command_modules/iot/custom.py index d6e0ea12dd2..5f354c82c1a 100644 --- a/src/azure-cli/azure/cli/command_modules/iot/custom.py +++ b/src/azure-cli/azure/cli/command_modules/iot/custom.py @@ -944,11 +944,11 @@ def iot_hub_get_stats(client, hub_name, resource_group_name=None): def validate_authentication_type_input(endpoint_type, connection_string=None, authentication_type=None, endpoint_uri=None, entity_path=None): is_keyBased = (AuthenticationType.KeyBased.value == authentication_type) or (authentication_type is None) - has_connection_string = (connection_string is not None) + has_connection_string = connection_string is not None if is_keyBased and not has_connection_string: raise CLIError("Please provide a connection string '--connection-string/-c'") - has_endpoint_uri = (endpoint_uri is not None) + has_endpoint_uri = endpoint_uri is not None has_endpoint_uri_and_path = (has_endpoint_uri) and (entity_path is not None) if EndpointType.AzureStorageContainer.value == endpoint_type.lower() and not has_endpoint_uri: raise CLIError("Please provide an endpoint uri '--endpoint-uri'") diff --git a/src/azure-cli/azure/cli/command_modules/keyvault/custom.py b/src/azure-cli/azure/cli/command_modules/keyvault/custom.py index 31a19d2de40..9419464d09b 100644 --- a/src/azure-cli/azure/cli/command_modules/keyvault/custom.py +++ b/src/azure-cli/azure/cli/command_modules/keyvault/custom.py @@ -1592,7 +1592,7 @@ def add_certificate_contact(cmd, client, email, name=None, phone=None): except ResourceNotFoundError: contacts = [] contact = CertificateContact(email=email, name=name, phone=phone) - if any((x for x in contacts if x.email == email)): + if any(x for x in contacts if x.email == email): raise CLIError("contact '{}' already exists".format(email)) contacts.append(contact) return client.set_contacts(contacts) @@ -1646,7 +1646,7 @@ def add_certificate_issuer_admin(cmd, client, issuer_name, email, first_name=Non mod='_models') issuer = client.get_issuer(issuer_name) admins = issuer.admin_contacts - if any((x for x in admins if x.email == email)): + if any(x for x in admins if x.email == email): raise CLIError("admin '{}' already exists".format(email)) new_admin = AdministratorContact(first_name=first_name, last_name=last_name, email=email, phone=phone) admins.append(new_admin) diff --git a/src/azure-cli/azure/cli/command_modules/lab/commands.py b/src/azure-cli/azure/cli/command_modules/lab/commands.py index 76e241432e4..1f83576818d 100644 --- a/src/azure-cli/azure/cli/command_modules/lab/commands.py +++ b/src/azure-cli/azure/cli/command_modules/lab/commands.py @@ -15,7 +15,7 @@ def load_command_table(self, _): with self.command_group('lab vm') as g: g.custom_command('claim', 'claim_vm', validator=validate_claim_vm) - with (self.command_group('lab vm')): + with self.command_group('lab vm'): from .custom import LabVmCreate, LabVmList, LabVmShow, LabVmDelete, LabVmStart, LabVmStop, \ LabVmApplyArtifacts self.command_table['lab vm create'] = LabVmCreate(loader=self) diff --git a/src/azure-cli/azure/cli/command_modules/monitor/grammar/autoscale/AutoscaleConditionParser.py b/src/azure-cli/azure/cli/command_modules/monitor/grammar/autoscale/AutoscaleConditionParser.py index 386b90c3012..d9069556b6c 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/grammar/autoscale/AutoscaleConditionParser.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/grammar/autoscale/AutoscaleConditionParser.py @@ -368,7 +368,7 @@ def namespace(self): while True: self.state = 65 _la = self._input.LA(1) - if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 83887102) != 0)): + if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 83887102) != 0): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -376,7 +376,7 @@ def namespace(self): self.state = 68 self._errHandler.sync(self) _la = self._input.LA(1) - if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & 83887102) != 0)): + if not (((_la) & ~0x3f) == 0 and ((1 << _la) & 83887102) != 0): break except RecognitionException as re: @@ -435,7 +435,7 @@ def metric(self): if _alt == 1: self.state = 70 _la = self._input.LA(1) - if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 83893494) != 0)): + if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 83893494) != 0): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -1077,7 +1077,7 @@ def dim_value(self): if _alt == 1: self.state = 121 _la = self._input.LA(1) - if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 88113244) != 0)): + if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 88113244) != 0): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) diff --git a/src/azure-cli/azure/cli/command_modules/monitor/grammar/metric_alert/MetricAlertConditionParser.py b/src/azure-cli/azure/cli/command_modules/monitor/grammar/metric_alert/MetricAlertConditionParser.py index de470e0ca7d..711c7f0c2ca 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/grammar/metric_alert/MetricAlertConditionParser.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/grammar/metric_alert/MetricAlertConditionParser.py @@ -448,7 +448,7 @@ def namespace(self): if _alt == 1: self.state = 94 _la = self._input.LA(1) - if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 1140850702) != 0)): + if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 1140850702) != 0): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -521,7 +521,7 @@ def metric(self): while True: self.state = 99 _la = self._input.LA(1) - if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 1409290238) != 0)): + if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 1409290238) != 0): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -529,7 +529,7 @@ def metric(self): self.state = 102 self._errHandler.sync(self) _la = self._input.LA(1) - if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & 1409290238) != 0)): + if not (((_la) & ~0x3f) == 0 and ((1 << _la) & 1409290238) != 0): break except RecognitionException as re: @@ -1046,7 +1046,7 @@ def dyn_datetime(self): while True: self.state = 140 _la = self._input.LA(1) - if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 1140854858) != 0)): + if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 1140854858) != 0): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -1054,7 +1054,7 @@ def dyn_datetime(self): self.state = 143 self._errHandler.sync(self) _la = self._input.LA(1) - if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & 1140854858) != 0)): + if not (((_la) & ~0x3f) == 0 and ((1 << _la) & 1140854858) != 0): break except RecognitionException as re: @@ -1560,7 +1560,7 @@ def dim_value(self): if _alt == 1: self.state = 183 _la = self._input.LA(1) - if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 1409311706) != 0)): + if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 1409311706) != 0): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) diff --git a/src/azure-cli/azure/cli/command_modules/netappfiles/custom.py b/src/azure-cli/azure/cli/command_modules/netappfiles/custom.py index 50a712dea78..fb614d18ad6 100644 --- a/src/azure-cli/azure/cli/command_modules/netappfiles/custom.py +++ b/src/azure-cli/azure/cli/command_modules/netappfiles/custom.py @@ -1020,7 +1020,7 @@ def create_data_volume_properties(subnet_id, application_identifier, pool_id, pp if data_repl_skd is not None and data_src_id is not None: replication = ({"replication_schedule": data_repl_skd, "remote_volume_resource_id": data_src_id}) - data_protection = ({"replication": replication}) + data_protection = {"replication": replication} data_volume = { "subnet_id": subnet_id, @@ -1200,7 +1200,7 @@ def create_log_backup_volume_properties(subnet_id, sap_sid, pool_id, ppg, memory # Memory should be sent in as GiB and additional snapshot capacity as percentage (0-200). Usage is returned in bytes. def calculate_usage_threshold(memory, volume_type, add_snap_capacity=50, total_host_count=1, data_size=50, log_size=50): if volume_type == VolumeType.DATA: - usage = ((add_snap_capacity / 100) * memory + memory) + usage = (add_snap_capacity / 100) * memory + memory return int(usage) * gib_scale if usage > 100 else 100 * gib_scale # MIN 100 GiB if volume_type == VolumeType.LOG: if memory < 512: @@ -1261,7 +1261,7 @@ def create_default_export_policy_for_vg(nfsv3=False): "kerberos5p_read_write": False, "allowed_clients": "0.0.0.0/0"}) rules.append(export_policy) - volume_export_policy = ({"rules": rules}) + volume_export_policy = {"rules": rules} return volume_export_policy diff --git a/src/azure-cli/azure/cli/command_modules/network/custom.py b/src/azure-cli/azure/cli/command_modules/network/custom.py index 0b0f20e9fca..8511c6abb29 100644 --- a/src/azure-cli/azure/cli/command_modules/network/custom.py +++ b/src/azure-cli/azure/cli/command_modules/network/custom.py @@ -3289,7 +3289,7 @@ def pre_operations(self): if has_value(args.express_route_port): args.provider = None args.peering_location = None - args.bandwidth_in_gbps = (converted_bandwidth / 1000.0) + args.bandwidth_in_gbps = converted_bandwidth / 1000.0 else: args.bandwidth_in_mbps = int(converted_bandwidth) diff --git a/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_common.py b/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_common.py index 42d1c49ca99..04f497cdb8d 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_common.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_common.py @@ -30,7 +30,7 @@ def flexible_server_update_get(client, resource_group_name, server_name): def flexible_server_stop(client, resource_group_name=None, server_name=None, no_wait=False): - if (not check_resource_group(resource_group_name)): + if not check_resource_group(resource_group_name): resource_group_name = None days = 7 @@ -46,7 +46,7 @@ def flexible_server_update_set(client, resource_group_name, server_name, paramet def server_list_custom_func(client, resource_group_name=None): - if (not check_resource_group(resource_group_name)): + if not check_resource_group(resource_group_name): resource_group_name = None if resource_group_name: @@ -148,7 +148,7 @@ def firewall_rule_list_func(cmd, client, resource_group_name, server_name): def database_delete_func(cmd, client, resource_group_name=None, server_name=None, database_name=None, yes=None): - if (not check_resource_group(resource_group_name)): + if not check_resource_group(resource_group_name): resource_group_name = None result = None diff --git a/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py b/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py index be92633044c..504d5df6558 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py @@ -62,7 +62,7 @@ def flexible_server_create(cmd, client, active_directory_auth=None, password_auth=None, auto_grow=None, performance_tier=None, storage_type=None, iops=None, throughput=None, create_default_db='Enabled', yes=False): - if (not check_resource_group(resource_group_name)): + if not check_resource_group(resource_group_name): resource_group_name = None # Generate missing parameters diff --git a/src/azure-cli/azure/cli/command_modules/rdbms/validators.py b/src/azure-cli/azure/cli/command_modules/rdbms/validators.py index 89fb456b8f6..9bf06ef5de9 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/validators.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/validators.py @@ -372,7 +372,7 @@ def _valid_ssdv2_range(storage_gb, sku_info, tier, iops, throughput, instance): supported_storageV2_size = sku_info[sku_tier]["supported_storageV2_size"] min_storage = instance.storage.storage_size_gb if instance is not None else supported_storageV2_size max_storage = sku_info[sku_tier]["supported_storageV2_size_max"] - if not (min_storage <= storage_gib <= max_storage): + if not min_storage <= storage_gib <= max_storage: raise CLIError('The requested value for storage size does not fall between {} and {} GiB.' .format(min_storage, max_storage)) @@ -384,7 +384,7 @@ def _valid_ssdv2_range(storage_gb, sku_info, tier, iops, throughput, instance): else: max_iops = math.floor(max(0, storage - 6) * 500 + min_iops) - if not (min_iops <= storage_iops <= max_iops): + if not min_iops <= storage_iops <= max_iops: raise CLIError('The requested value for IOPS does not fall between {} and {} operations/sec.' .format(min_iops, max_iops)) @@ -399,7 +399,7 @@ def _valid_ssdv2_range(storage_gb, sku_info, tier, iops, throughput, instance): else: max_throughout = max_storage_throughout - if not (min_throughout <= storage_throughput <= max_throughout): + if not min_throughout <= storage_throughput <= max_throughout: raise CLIError('The requested value for throughput does not fall between {} and {} MB/sec.' .format(min_throughout, max_throughout)) @@ -837,7 +837,7 @@ def _pg_storage_type_validator(storage_type, auto_grow, high_availability, geo_r def check_resource_group(resource_group_name): # check if rg is already null originally - if (not resource_group_name): + if not resource_group_name: return False # replace single and double quotes with empty string @@ -845,11 +845,11 @@ def check_resource_group(resource_group_name): resource_group_name = resource_group_name.replace('"', '') # check if rg is empty after removing quotes - if (not resource_group_name): + if not resource_group_name: return False return True def validate_resource_group(resource_group_name): - if (not check_resource_group(resource_group_name)): + if not check_resource_group(resource_group_name): raise CLIError('Resource group name cannot be empty.') diff --git a/src/azure-cli/azure/cli/command_modules/resource/custom.py b/src/azure-cli/azure/cli/command_modules/resource/custom.py index 49229be27fc..74181ca85b4 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/custom.py +++ b/src/azure-cli/azure/cli/command_modules/resource/custom.py @@ -643,7 +643,7 @@ def _deploy_arm_template_at_resource_group(cmd, no_prompt=no_prompt, template_spec=template_spec, query_string=query_string) mgmt_client = _get_deployment_management_client(cmd.cli_ctx, aux_subscriptions=aux_subscriptions, - aux_tenants=aux_tenants, plug_pipeline=(deployment_properties.template_link is None)) + aux_tenants=aux_tenants, plug_pipeline=deployment_properties.template_link is None) from azure.core.exceptions import HttpResponseError Deployment = cmd.get_models('Deployment') @@ -734,7 +734,7 @@ def _deploy_arm_template_at_management_group(cmd, parameters=parameters, mode=mode, no_prompt=no_prompt, template_spec=template_spec, query_string=query_string) - mgmt_client = _get_deployment_management_client(cmd.cli_ctx, plug_pipeline=(deployment_properties.template_link is None)) + mgmt_client = _get_deployment_management_client(cmd.cli_ctx, plug_pipeline=deployment_properties.template_link is None) from azure.core.exceptions import HttpResponseError ScopedDeployment = cmd.get_models('ScopedDeployment') @@ -818,7 +818,7 @@ def _deploy_arm_template_at_tenant_scope(cmd, parameters=parameters, mode='Incremental', no_prompt=no_prompt, template_spec=template_spec, query_string=query_string,) - mgmt_client = _get_deployment_management_client(cmd.cli_ctx, plug_pipeline=(deployment_properties.template_link is None)) + mgmt_client = _get_deployment_management_client(cmd.cli_ctx, plug_pipeline=deployment_properties.template_link is None) from azure.core.exceptions import HttpResponseError ScopedDeployment = cmd.get_models('ScopedDeployment') @@ -868,7 +868,7 @@ def _what_if_deploy_arm_template_at_resource_group_core(cmd, resource_group_name what_if_properties = _prepare_deployment_what_if_properties(cmd, 'resourceGroup', template_file, template_uri, parameters, mode, result_format, no_prompt, template_spec, query_string) mgmt_client = _get_deployment_management_client(cmd.cli_ctx, aux_tenants=aux_tenants, - plug_pipeline=(what_if_properties.template_link is None)) + plug_pipeline=what_if_properties.template_link is None) DeploymentWhatIf = cmd.get_models('DeploymentWhatIf') deployment_what_if = DeploymentWhatIf(properties=what_if_properties) what_if_poller = mgmt_client.begin_what_if(resource_group_name, deployment_name, @@ -898,7 +898,7 @@ def _what_if_deploy_arm_template_at_subscription_scope_core(cmd, return_result=None): what_if_properties = _prepare_deployment_what_if_properties(cmd, 'subscription', template_file, template_uri, parameters, DeploymentMode.incremental, result_format, no_prompt, template_spec, query_string) - mgmt_client = _get_deployment_management_client(cmd.cli_ctx, plug_pipeline=(what_if_properties.template_link is None)) + mgmt_client = _get_deployment_management_client(cmd.cli_ctx, plug_pipeline=what_if_properties.template_link is None) ScopedDeploymentWhatIf = cmd.get_models('ScopedDeploymentWhatIf') scoped_deployment_what_if = ScopedDeploymentWhatIf(location=deployment_location, properties=what_if_properties) what_if_poller = mgmt_client.begin_what_if_at_subscription_scope(deployment_name, @@ -928,7 +928,7 @@ def _what_if_deploy_arm_template_at_management_group_core(cmd, management_group_ return_result=None): what_if_properties = _prepare_deployment_what_if_properties(cmd, 'managementGroup', template_file, template_uri, parameters, DeploymentMode.incremental, result_format, no_prompt, template_spec=template_spec, query_string=query_string) - mgmt_client = _get_deployment_management_client(cmd.cli_ctx, plug_pipeline=(what_if_properties.template_link is None)) + mgmt_client = _get_deployment_management_client(cmd.cli_ctx, plug_pipeline=what_if_properties.template_link is None) ScopedDeploymentWhatIf = cmd.get_models('ScopedDeploymentWhatIf') scoped_deployment_what_if = ScopedDeploymentWhatIf(location=deployment_location, properties=what_if_properties) what_if_poller = mgmt_client.begin_what_if_at_management_group_scope(management_group_id, deployment_name, @@ -958,7 +958,7 @@ def _what_if_deploy_arm_template_at_tenant_scope_core(cmd, return_result=None): what_if_properties = _prepare_deployment_what_if_properties(cmd, 'tenant', template_file, template_uri, parameters, DeploymentMode.incremental, result_format, no_prompt, template_spec, query_string) - mgmt_client = _get_deployment_management_client(cmd.cli_ctx, plug_pipeline=(what_if_properties.template_link is None)) + mgmt_client = _get_deployment_management_client(cmd.cli_ctx, plug_pipeline=what_if_properties.template_link is None) ScopedDeploymentWhatIf = cmd.get_models('ScopedDeploymentWhatIf') scoped_deployment_what_if = ScopedDeploymentWhatIf(location=deployment_location, properties=what_if_properties) what_if_poller = mgmt_client.begin_what_if_at_tenant_scope(deployment_name, parameters=scoped_deployment_what_if) @@ -4021,7 +4021,7 @@ def _validate_lock_params_match_lock( if resource.get('child_type_3', None) is None: _resource_type = resource.get('child_type_1', None) _resource_name = resource.get('child_name_1', None) - parent = (resource['type'] + '/' + resource['name']) + parent = resource['type'] + '/' + resource['name'] else: _resource_type = resource.get('child_type_2', None) _resource_name = resource.get('child_name_2', None) diff --git a/src/azure-cli/azure/cli/command_modules/role/_params.py b/src/azure-cli/azure/cli/command_modules/role/_params.py index 934ee60de06..65fb7fc4923 100644 --- a/src/azure-cli/azure/cli/command_modules/role/_params.py +++ b/src/azure-cli/azure/cli/command_modules/role/_params.py @@ -326,7 +326,7 @@ def load_arguments(self, _): c.argument('assignment_name', name_arg_type, help='A GUID for the role assignment. It must be unique and different for each role assignment. If omitted, a new GUID is generated.') - time_help = ('The {} of the query in the format of %Y-%m-%dT%H:%M:%SZ, e.g. 2000-12-31T12:59:59Z. Defaults to {}') + time_help = 'The {} of the query in the format of %Y-%m-%dT%H:%M:%SZ, e.g. 2000-12-31T12:59:59Z. Defaults to {}' with self.argument_context('role assignment list-changelogs') as c: c.argument('start_time', help=time_help.format('start time', '1 Hour prior to the current time')) c.argument('end_time', help=time_help.format('end time', 'the current time')) diff --git a/src/azure-cli/azure/cli/command_modules/role/_validators.py b/src/azure-cli/azure/cli/command_modules/role/_validators.py index 5ecfa85454f..80020c8c945 100644 --- a/src/azure-cli/azure/cli/command_modules/role/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/role/_validators.py @@ -19,8 +19,8 @@ def _get_group_count_and_id(namespace, group_filter): def validate_group(namespace): # For AD auto-commands, here we resolve logic names to object ids needed by SDK methods - attr, value = next(((x, getattr(namespace, x)) for x in VARIANT_GROUP_ID_ARGS - if hasattr(namespace, x))) + attr, value = next((x, getattr(namespace, x)) for x in VARIANT_GROUP_ID_ARGS + if hasattr(namespace, x)) try: uuid.UUID(value) except ValueError: diff --git a/src/azure-cli/azure/cli/command_modules/serviceconnector/commands.py b/src/azure-cli/azure/cli/command_modules/serviceconnector/commands.py index 232bd3c32ff..189a1c42dfb 100644 --- a/src/azure-cli/azure/cli/command_modules/serviceconnector/commands.py +++ b/src/azure-cli/azure/cli/command_modules/serviceconnector/commands.py @@ -42,7 +42,7 @@ def load_command_table(self, _): # pylint: disable=too-many-statements # if source resource is released as an extension, load our command groups # only when the extension is installed if should_load_source(source): - is_preview_source = (source == RESOURCE.KubernetesCluster) + is_preview_source = source == RESOURCE.KubernetesCluster with self.command_group('{} connection'.format(source.value), connection_type, client_factory=cf_linker, is_preview=is_preview_source) as og: diff --git a/src/azure-cli/azure/cli/command_modules/sql/_format.py b/src/azure-cli/azure/cli/command_modules/sql/_format.py index b6266452aef..cfc76c89757 100644 --- a/src/azure-cli/azure/cli/command_modules/sql/_format.py +++ b/src/azure-cli/azure/cli/command_modules/sql/_format.py @@ -27,7 +27,7 @@ def _bytes_to_friendly_string(b): unit = next(u for u in _units if (b % u[0]) == 0) # Format the value with the chosen unit - return str((b // unit[0])) + unit[1] + return str(b // unit[0]) + unit[1] class LongRunningOperationResultTransform(LongRunningOperation): # pylint: disable=too-few-public-methods diff --git a/src/azure-cli/azure/cli/command_modules/sql/custom.py b/src/azure-cli/azure/cli/command_modules/sql/custom.py index 874d22865df..147cc5e0695 100644 --- a/src/azure-cli/azure/cli/command_modules/sql/custom.py +++ b/src/azure-cli/azure/cli/command_modules/sql/custom.py @@ -760,7 +760,7 @@ def _to_filetimeutc(dateTime): NET_epoch = datetime(1601, 1, 1) UNIX_epoch = datetime(1970, 1, 1) - epoch_delta = (UNIX_epoch - NET_epoch) + epoch_delta = UNIX_epoch - NET_epoch log_time = parse(dateTime) diff --git a/src/azure-cli/azure/cli/command_modules/storage/_transformers_azure_stack.py b/src/azure-cli/azure/cli/command_modules/storage/_transformers_azure_stack.py index 0bbac805d86..eb5ce1d13d8 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/_transformers_azure_stack.py +++ b/src/azure-cli/azure/cli/command_modules/storage/_transformers_azure_stack.py @@ -42,10 +42,10 @@ def transform_cors_list_output(result): new_entry['Service'] = service new_entry['Rule'] = i + 1 - new_entry['AllowedMethods'] = ', '.join((x for x in rule.allowed_methods)) - new_entry['AllowedOrigins'] = ', '.join((x for x in rule.allowed_origins)) - new_entry['ExposedHeaders'] = ', '.join((x for x in rule.exposed_headers)) - new_entry['AllowedHeaders'] = ', '.join((x for x in rule.allowed_headers)) + new_entry['AllowedMethods'] = ', '.join(x for x in rule.allowed_methods) + new_entry['AllowedOrigins'] = ', '.join(x for x in rule.allowed_origins) + new_entry['ExposedHeaders'] = ', '.join(x for x in rule.exposed_headers) + new_entry['AllowedHeaders'] = ', '.join(x for x in rule.allowed_headers) new_entry['MaxAgeInSeconds'] = rule.max_age_in_seconds new_result.append(new_entry) return new_result diff --git a/src/azure-cli/azure/cli/command_modules/util/custom.py b/src/azure-cli/azure/cli/command_modules/util/custom.py index 4834a261413..167b51c72b4 100644 --- a/src/azure-cli/azure/cli/command_modules/util/custom.py +++ b/src/azure-cli/azure/cli/command_modules/util/custom.py @@ -222,7 +222,7 @@ def _upgrade_on_windows(): def _download_from_url(url, target_dir): import requests from azure.cli.core.util import should_disable_connection_verify - r = requests.get(url, stream=True, verify=(not should_disable_connection_verify())) + r = requests.get(url, stream=True, verify=not should_disable_connection_verify()) if r.status_code != 200: raise CLIError("Request to {} failed with {}".format(url, r.status_code)) diff --git a/src/azure-cli/azure/cli/command_modules/vm/_actions.py b/src/azure-cli/azure/cli/command_modules/vm/_actions.py index d6341d3331a..512c233139c 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_actions.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_actions.py @@ -144,7 +144,7 @@ def load_images_from_aliases_doc(cli_ctx, publisher=None, offer=None, sku=None, else: # under hack mode(say through proxies with unsigned cert), opt out the cert verification try: - response = requests.get(target_url, verify=(not should_disable_connection_verify())) + response = requests.get(target_url, verify=not should_disable_connection_verify()) if response.status_code == 200: dic = json.loads(response.content.decode()) else: @@ -157,7 +157,7 @@ def load_images_from_aliases_doc(cli_ctx, publisher=None, offer=None, sku=None, dic = json.loads(alias_json) try: all_images = [] - result = (dic['outputs']['aliases']['value']) + result = dic['outputs']['aliases']['value'] for v in result.values(): # loop around os for alias, vv in v.items(): # loop around distros all_images.append({ diff --git a/src/azure-cli/azure/cli/command_modules/vm/_validators.py b/src/azure-cli/azure/cli/command_modules/vm/_validators.py index 39ab11ca573..272fe0cd567 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_validators.py @@ -1112,7 +1112,7 @@ def _validate_vm_nic_delete_option(namespace): if not namespace.nics and namespace.nic_delete_option: if len(namespace.nic_delete_option) == 1 and len(namespace.nic_delete_option[0].split('=')) == 1: # pylint: disable=line-too-long namespace.nic_delete_option = namespace.nic_delete_option[0] - elif len(namespace.nic_delete_option) > 1 or any((len(delete_option.split('=')) > 1 for delete_option in namespace.nic_delete_option)): # pylint: disable=line-too-long + elif len(namespace.nic_delete_option) > 1 or any(len(delete_option.split('=')) > 1 for delete_option in namespace.nic_delete_option): # pylint: disable=line-too-long from azure.cli.core.parser import InvalidArgumentValueError raise InvalidArgumentValueError("incorrect usage: Cannot specify individual delete option when no nic is " "specified. Either specify a list of nics and their delete option like: " @@ -1194,7 +1194,7 @@ def _validate_admin_username(username, os_type): import re if not username: raise CLIError("admin user name can not be empty") - is_linux = (os_type.lower() == 'linux') + is_linux = os_type.lower() == 'linux' # pylint: disable=line-too-long pattern = (r'[\\\/"\[\]:|<>+=;,?*@#()!A-Z]+' if is_linux else r'[\\\/"\[\]:|<>+=;,?*@]+') linux_err = r'admin user name cannot contain upper case character A-Z, special characters \/"[]:|<>+=;,?*@#()! or start with $ or -' @@ -1212,7 +1212,7 @@ def _validate_admin_username(username, os_type): def _validate_admin_password(password, os_type): import re - is_linux = (os_type.lower() == 'linux') + is_linux = os_type.lower() == 'linux' max_length = 72 if is_linux else 123 min_length = 12 diff --git a/src/azure-cli/azure/cli/command_modules/vm/azure_stack/_actions.py b/src/azure-cli/azure/cli/command_modules/vm/azure_stack/_actions.py index 8b70419c208..28c5b8d1327 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/azure_stack/_actions.py +++ b/src/azure-cli/azure/cli/command_modules/vm/azure_stack/_actions.py @@ -143,7 +143,7 @@ def load_images_from_aliases_doc(cli_ctx, publisher=None, offer=None, sku=None, else: # under hack mode(say through proxies with unsigned cert), opt out the cert verification try: - response = requests.get(target_url, verify=(not should_disable_connection_verify())) + response = requests.get(target_url, verify=not should_disable_connection_verify()) if response.status_code == 200: dic = json.loads(response.content.decode()) else: @@ -156,7 +156,7 @@ def load_images_from_aliases_doc(cli_ctx, publisher=None, offer=None, sku=None, dic = json.loads(alias_json) try: all_images = [] - result = (dic['outputs']['aliases']['value']) + result = dic['outputs']['aliases']['value'] for v in result.values(): # loop around os for alias, vv in v.items(): # loop around distros all_images.append({ diff --git a/src/azure-cli/azure/cli/command_modules/vm/azure_stack/_validators.py b/src/azure-cli/azure/cli/command_modules/vm/azure_stack/_validators.py index b4094b033a6..77743da1335 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/azure_stack/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/vm/azure_stack/_validators.py @@ -1202,7 +1202,7 @@ def _validate_admin_username(username, os_type): import re if not username: raise CLIError("admin user name can not be empty") - is_linux = (os_type.lower() == 'linux') + is_linux = os_type.lower() == 'linux' # pylint: disable=line-too-long pattern = (r'[\\\/"\[\]:|<>+=;,?*@#()!A-Z]+' if is_linux else r'[\\\/"\[\]:|<>+=;,?*@]+') linux_err = r'admin user name cannot contain upper case character A-Z, special characters \/"[]:|<>+=;,?*@#()! or start with $ or -' @@ -1222,7 +1222,7 @@ def _validate_admin_username(username, os_type): def _validate_admin_password(password, os_type): import re - is_linux = (os_type.lower() == 'linux') + is_linux = os_type.lower() == 'linux' max_length = 72 if is_linux else 123 min_length = 12 diff --git a/src/azure-cli/azure/cli/command_modules/vm/azure_stack/custom.py b/src/azure-cli/azure/cli/command_modules/vm/azure_stack/custom.py index 2a30bec9a9f..38ad192cae0 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/azure_stack/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/azure_stack/custom.py @@ -5863,7 +5863,7 @@ def set_vm_applications(cmd, vm_name, resource_group_name, application_version_i index = 0 for treat_as_failure in treat_deployment_as_failure: vm.application_profile.gallery_applications[index].treat_failure_as_deployment_failure = \ - (treat_as_failure.lower() == 'true') + treat_as_failure.lower() == 'true' index += 1 return sdk_no_wait(no_wait, client.virtual_machines.begin_create_or_update, resource_group_name, vm_name, vm) @@ -5907,7 +5907,7 @@ def set_vmss_applications(cmd, vmss_name, resource_group_name, application_versi index = 0 for treat_as_failure in treat_deployment_as_failure: vmss.virtual_machine_profile.application_profile.gallery_applications[ - index].treat_failure_as_deployment_failure = (treat_as_failure.lower() == 'true') + index].treat_failure_as_deployment_failure = treat_as_failure.lower() == 'true' index += 1 return sdk_no_wait(no_wait, client.virtual_machine_scale_sets.begin_create_or_update, resource_group_name, vmss_name, vmss) diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index a9d8990d4a2..e4c782abebe 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -1501,7 +1501,7 @@ def open_vm_port(cmd, resource_group_name, vm_name, port, priority=900, network_ # update the NSG with the new rule to allow inbound traffic - rule_name = 'open-port-all' if port == '*' else 'open-port-{}'.format((port.replace(',', '_'))) + rule_name = 'open-port-all' if port == '*' else 'open-port-{}'.format(port.replace(',', '_')) # use portranges if multiple ports are entered if "," not in port: @@ -2587,7 +2587,7 @@ def _build_nic_list(cmd, nic_ids): 'name': name, 'resource_group': rg }) - nic_list.append((NetworkInterfaceReference(id=nic['id'], primary=False))) + nic_list.append(NetworkInterfaceReference(id=nic['id'], primary=False)) return nic_list @@ -5793,7 +5793,7 @@ def set_vm_applications(cmd, vm_name, resource_group_name, application_version_i index = 0 for treat_as_failure in treat_deployment_as_failure: vm.application_profile.gallery_applications[index].treat_failure_as_deployment_failure = \ - (treat_as_failure.lower() == 'true') + treat_as_failure.lower() == 'true' index += 1 return sdk_no_wait(no_wait, client.virtual_machines.begin_create_or_update, resource_group_name, vm_name, vm) @@ -5833,7 +5833,7 @@ def set_vmss_applications(cmd, vmss_name, resource_group_name, application_versi if treat_deployment_as_failure: index = 0 for treat_as_failure in treat_deployment_as_failure: - vmss.virtual_machine_profile.application_profile.gallery_applications[index].treat_failure_as_deployment_failure = (treat_as_failure.lower() == 'true') + vmss.virtual_machine_profile.application_profile.gallery_applications[index].treat_failure_as_deployment_failure = treat_as_failure.lower() == 'true' index += 1 return sdk_no_wait(no_wait, client.virtual_machine_scale_sets.begin_create_or_update, resource_group_name, vmss_name, vmss)