From 8481a92267566cc4375a6cdd2b0c8517ef68287b Mon Sep 17 00:00:00 2001 From: Jiashuo Li <4003950+jiasli@users.noreply.github.com> Date: Fri, 18 Jun 2021 10:54:17 +0800 Subject: [PATCH] {Pylint} Fix `use-a-generator` (#18523) --- pylintrc | 2 -- src/azure-cli-core/azure/cli/core/commands/__init__.py | 2 +- .../azure/cli/command_modules/appservice/custom.py | 2 +- .../azure/cli/command_modules/batch/_command_type.py | 6 +++--- .../azure/cli/command_modules/cdn/custom/custom_afdx.py | 8 ++++---- .../monitor/operations/activity_log_alerts.py | 2 +- .../azure/cli/command_modules/network/_validators.py | 2 +- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/pylintrc b/pylintrc index 7e48385dfad..d60a12736f5 100644 --- a/pylintrc +++ b/pylintrc @@ -12,7 +12,6 @@ reports=no disable= arguments-out-of-order, bad-option-value, - consider-using-generator, consider-using-with, cyclic-import, duplicate-code, @@ -32,7 +31,6 @@ disable= too-many-arguments, too-many-function-args, too-many-lines, - use-a-generator, using-constant-test, wrong-import-order, diff --git a/src/azure-cli-core/azure/cli/core/commands/__init__.py b/src/azure-cli-core/azure/cli/core/commands/__init__.py index 196a1fe05cf..d2f049e7471 100644 --- a/src/azure-cli-core/azure/cli/core/commands/__init__.py +++ b/src/azure-cli-core/azure/cli/core/commands/__init__.py @@ -107,7 +107,7 @@ def _expand_file_prefix(arg): except IndexError: return _maybe_load_file(arg_split[0]) - return list([_expand_file_prefix(arg) for arg in args]) + return [_expand_file_prefix(arg) for arg in args] def _pre_command_table_create(cli_ctx, args): 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 e33d7dfea7c..f6a2b01707c 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/custom.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/custom.py @@ -1099,7 +1099,7 @@ def url_validator(url): def _get_linux_multicontainer_decoded_config(cmd, resource_group_name, name, slot=None): from base64 import b64decode linux_fx_version = _get_fx_version(cmd, resource_group_name, name, slot) - if not any([linux_fx_version.startswith(s) for s in MULTI_CONTAINER_TYPES]): + if not any(linux_fx_version.startswith(s) for s in MULTI_CONTAINER_TYPES): raise CLIError("Cannot decode config that is not one of the" " following types: {}".format(','.join(MULTI_CONTAINER_TYPES))) return b64decode(linux_fx_version.split('|')[1].encode('utf-8')) 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 34f8a61e5e6..789d64c9559 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 @@ -250,7 +250,7 @@ def _parse(self, namespace, path, required): required_args = [] children = self._get_children(path) if not required: - if not any([getattr(namespace, n) for n in children]): + if not any(getattr(namespace, n) for n in children): return [] siblings = self._get_siblings(path) if not siblings: @@ -377,7 +377,7 @@ def parse_mutually_exclusive(self, namespace, required, params): child_args = self._get_children(arg_group) if child_args: ex_group_names.append(group_title(arg_group)) - if any([getattr(namespace, arg) for arg in child_args]): + if any(getattr(namespace, arg) for arg in child_args): ex_groups.append(ex_group_names[-1]) message = None @@ -613,7 +613,7 @@ def _get_attrs(self, model, path): model._validation.get(attr, {}).get('readonly')) # pylint: disable=protected-access conditions.append( model._validation.get(attr, {}).get('constant')) # pylint: disable=protected-access - conditions.append(any([i for i in pformat.IGNORE_PARAMETERS if i in full_path])) + conditions.append(any(i for i in pformat.IGNORE_PARAMETERS if i in full_path)) conditions.append(details['type'][0] in ['{']) if not any(conditions): yield attr, details diff --git a/src/azure-cli/azure/cli/command_modules/cdn/custom/custom_afdx.py b/src/azure-cli/azure/cli/command_modules/cdn/custom/custom_afdx.py index aa3bd2cff9a..c3ecf20771c 100644 --- a/src/azure-cli/azure/cli/command_modules/cdn/custom/custom_afdx.py +++ b/src/azure-cli/azure/cli/command_modules/cdn/custom/custom_afdx.py @@ -663,8 +663,8 @@ def create_afd_security_policy(client: SecurityPoliciesOperations, domains: List[str], waf_policy: str): - if any([("/afdendpoints/" not in domain.lower() and - "/customdomains/" not in domain.lower()) for domain in domains]): + if any(("/afdendpoints/" not in domain.lower() and + "/customdomains/" not in domain.lower()) for domain in domains): raise InvalidArgumentValueError('Domain should either be endpoint ID or custom domain ID.') if "/frontdoorwebapplicationfirewallpolicies/" not in waf_policy.lower(): @@ -690,8 +690,8 @@ def update_afd_security_policy(client: SecurityPoliciesOperations, domains: List[str] = None, waf_policy: str = None): - if domains is not None and any([("/afdendpoints/" not in domain.lower() and - "/customdomains/" not in domain.lower()) for domain in domains]): + if domains is not None and any(("/afdendpoints/" not in domain.lower() and + "/customdomains/" not in domain.lower()) for domain in domains): raise InvalidArgumentValueError('Domain should be either endpoint ID or custom domain ID.') if waf_policy is not None and "/frontdoorwebapplicationfirewallpolicies/" not in waf_policy: diff --git a/src/azure-cli/azure/cli/command_modules/monitor/operations/activity_log_alerts.py b/src/azure-cli/azure/cli/command_modules/monitor/operations/activity_log_alerts.py index 5f5dba78f16..3293d78b582 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/operations/activity_log_alerts.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/operations/activity_log_alerts.py @@ -35,7 +35,7 @@ def process_condition_parameter(namespace): # Ensure all the string at even options are AND operator operators = [expression[i] for i in range(1, len(expression), 2)] - if any([op != 'and' for op in operators]): + if any(op != 'and' for op in operators): raise CLIError(error) # Pick the strings at odd position and convert them into condition leaf. diff --git a/src/azure-cli/azure/cli/command_modules/network/_validators.py b/src/azure-cli/azure/cli/command_modules/network/_validators.py index 240d85d79d0..9354f92087e 100644 --- a/src/azure-cli/azure/cli/command_modules/network/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/network/_validators.py @@ -259,7 +259,7 @@ def validate_trusted_client_cert(namespace): def validate_ssl_cert(namespace): params = [namespace.cert_data, namespace.cert_password] - if all([not x for x in params]) and not namespace.key_vault_secret_id: + if all(not x for x in params) and not namespace.key_vault_secret_id: # no cert supplied -- use HTTP if not namespace.frontend_port: namespace.frontend_port = 80