diff --git a/pylintrc b/pylintrc index bbf7f0544f9..ebd912ec874 100644 --- a/pylintrc +++ b/pylintrc @@ -41,7 +41,6 @@ disable= unspecified-encoding, use-maxsplit-arg, arguments-renamed, - consider-using-in, use-dict-literal, consider-using-dict-items, consider-using-enumerate, diff --git a/src/azure-cli-core/azure/cli/core/aaz/_arg.py b/src/azure-cli-core/azure/cli/core/aaz/_arg.py index 14553b2048d..c43eb7f9c1c 100644 --- a/src/azure-cli-core/azure/cli/core/aaz/_arg.py +++ b/src/azure-cli-core/azure/cli/core/aaz/_arg.py @@ -65,7 +65,7 @@ def __getitem__(self, data): if isinstance(self.items, dict): # convert data, it can be key, value or key.lower() when not case sensitive for k, v in self.items.items(): - if v == data or k == data or not self._case_sensitive and k.lower() == data.lower(): + if data in (v, k) or not self._case_sensitive and k.lower() == data.lower(): key = k break diff --git a/src/azure-cli-core/azure/cli/core/aaz/_operation.py b/src/azure-cli-core/azure/cli/core/aaz/_operation.py index 31283d4beb5..dc550080262 100644 --- a/src/azure-cli-core/azure/cli/core/aaz/_operation.py +++ b/src/azure-cli-core/azure/cli/core/aaz/_operation.py @@ -55,7 +55,7 @@ def serialize_url_param(name, value, required=True, skip_quote=False, **kwargs): if isinstance(value, AAZBaseValue): value = value.to_serialized_data() - if value == AAZUndefined or value == None: # noqa: E711, pylint: disable=singleton-comparison + if value in (AAZUndefined, None): # noqa: E711, pylint: disable=singleton-comparison if required: raise ValueError(f"url parameter {name} is required.") return {} # return empty dict @@ -204,7 +204,7 @@ def processor(schema, result): else: data = value - if data == AAZUndefined or data == None: # noqa: E711, pylint: disable=singleton-comparison + if data in (AAZUndefined, None): # noqa: E711, pylint: disable=singleton-comparison if required: raise ValueError("Missing request content") return None 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..3600f20da4b 100644 --- a/src/azure-cli-core/azure/cli/core/extension/operations.py +++ b/src/azure-cli-core/azure/cli/core/extension/operations.py @@ -86,7 +86,7 @@ def _validate_whl_extension(ext_file): def _get_extension_info_from_source(source): url_parse_result = urlparse(source) - is_url = (url_parse_result.scheme == 'http' or url_parse_result.scheme == 'https') + is_url = (url_parse_result.scheme in ('http', 'https')) whl_filename = os.path.basename(url_parse_result.path) if is_url else os.path.basename(source) parsed_filename = WHEEL_INFO_RE(whl_filename) # Extension names can have - but .whl format changes it to _ (PEP 0427). Undo this. @@ -100,7 +100,7 @@ def _add_whl_ext(cli_ctx, source, ext_sha256=None, pip_extra_index_urls=None, pi if not source.endswith('.whl'): raise ValueError('Unknown extension type. Only Python wheels are supported.') url_parse_result = urlparse(source) - is_url = (url_parse_result.scheme == 'http' or url_parse_result.scheme == 'https') + is_url = (url_parse_result.scheme in ('http', 'https')) logger.debug('Extension source is url? %s', is_url) whl_filename = os.path.basename(url_parse_result.path) if is_url else os.path.basename(source) parsed_filename = WHEEL_INFO_RE(whl_filename) @@ -110,7 +110,7 @@ def _add_whl_ext(cli_ctx, source, ext_sha256=None, pip_extra_index_urls=None, pi raise CLIError('Unable to determine extension name from {}. Is the file name correct?'.format(source)) if extension_exists(extension_name, ext_type=WheelExtension): raise CLIError('The extension {} already exists.'.format(extension_name)) - if extension_name == 'rdbms-connect' or extension_name == 'serviceconnector-passwordless': + if extension_name in ('rdbms-connect', 'serviceconnector-passwordless'): _install_deps_for_psycopg2() ext_file = None if is_url: diff --git a/src/azure-cli/azure/cli/command_modules/acr/_agentpool_polling.py b/src/azure-cli/azure/cli/command_modules/acr/_agentpool_polling.py index 3b6d59eabca..db30267e49a 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/_agentpool_polling.py +++ b/src/azure-cli/azure/cli/command_modules/acr/_agentpool_polling.py @@ -84,7 +84,7 @@ def resource(self): def _set_operation_status(self, response): AgentPoolStatus = self._cmd.get_models('ProvisioningState') - if response.http_response.status_code == 200 or response.http_response.status_code == 404: + if response.http_response.status_code in (200, 404): self.operation_result = self._deserialize(response) self.operation_status = self.operation_result.provisioning_state or AgentPoolStatus.succeeded.value return 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 f8fa8d6339e..434e4e39d4c 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 @@ -625,7 +625,7 @@ def request_data_from_registry(http_method, result = response.json()[result_index] if result_index else response.json() next_link = response.headers['link'] if 'link' in response.headers else None return result, next_link, response.status_code - if response.status_code == 201 or response.status_code == 202: + if response.status_code in (201, 202): result = None try: result = response.json()[result_index] if result_index else response.json() diff --git a/src/azure-cli/azure/cli/command_modules/acr/artifact_streaming.py b/src/azure-cli/azure/cli/command_modules/acr/artifact_streaming.py index 08b45eeb98b..0e1da62ce41 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/artifact_streaming.py +++ b/src/azure-cli/azure/cli/command_modules/acr/artifact_streaming.py @@ -168,7 +168,7 @@ def _get_last_streaming_operation(cmd, def _is_ongoing_streaming_status(status): - res = status == ArtifactStreamingStatus.Running.value or status == ArtifactStreamingStatus.NotStarted.value + res = status in (ArtifactStreamingStatus.Running.value, ArtifactStreamingStatus.NotStarted.value) return res 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..7e039762e21 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_validators.py @@ -312,8 +312,7 @@ def validate_priority(namespace): if namespace.priority is not None: if namespace.priority == '': return - if namespace.priority != "Spot" and \ - namespace.priority != "Regular": + if namespace.priority not in ('Spot', 'Regular'): raise CLIError("--priority can only be Spot or Regular") @@ -322,8 +321,7 @@ def validate_eviction_policy(namespace): if namespace.eviction_policy is not None: if namespace.eviction_policy == '': return - if namespace.eviction_policy != "Delete" and \ - namespace.eviction_policy != "Deallocate": + if namespace.eviction_policy not in ('Delete', 'Deallocate'): raise CLIError("--eviction-policy can only be Delete or Deallocate") diff --git a/src/azure-cli/azure/cli/command_modules/acs/agentpool_decorator.py b/src/azure-cli/azure/cli/command_modules/acs/agentpool_decorator.py index f94179d08c3..c3fd19155c1 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/agentpool_decorator.py +++ b/src/azure-cli/azure/cli/command_modules/acs/agentpool_decorator.py @@ -644,7 +644,7 @@ def _get_os_type(self, read_only: bool = False) -> Union[str, None]: raw_os_sku = self.raw_param.get("os_sku") sku_2019 = CONST_OS_SKU_WINDOWS2019 sku_2022 = CONST_OS_SKU_WINDOWS2022 - if raw_os_sku == sku_2019 or raw_os_sku == sku_2022: + if raw_os_sku in (sku_2019, sku_2022): raise InvalidArgumentValueError( "OS SKU is invalid for Linux OS Type." " Please specify '--os-type Windows' for Windows SKUs" diff --git a/src/azure-cli/azure/cli/command_modules/acs/azurecontainerstorage/_validators.py b/src/azure-cli/azure/cli/command_modules/acs/azurecontainerstorage/_validators.py index 2733c5f8d97..677ff782b60 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/azurecontainerstorage/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/acs/azurecontainerstorage/_validators.py @@ -153,8 +153,7 @@ def validate_disable_azure_container_storage_params( # pylint: disable=too-many number_of_storagepool_types_active += 1 number_of_storagepool_types_to_be_disabled = 0 - if storage_pool_type == CONST_STORAGE_POOL_TYPE_AZURE_DISK or \ - storage_pool_type == CONST_STORAGE_POOL_TYPE_ELASTIC_SAN or \ + if storage_pool_type in (CONST_STORAGE_POOL_TYPE_AZURE_DISK, CONST_STORAGE_POOL_TYPE_ELASTIC_SAN) or \ (storage_pool_type == CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK and storage_pool_option != CONST_ACSTOR_ALL): number_of_storagepool_types_to_be_disabled = 1 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 9f2ac7a36b2..e8d29be0a22 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/custom.py @@ -879,7 +879,7 @@ def aks_upgrade(cmd, disable_force_upgrade=disable_force_upgrade, upgrade_override_until=upgrade_override_until) - if instance.kubernetes_version == kubernetes_version or kubernetes_version == '': + if kubernetes_version in (instance.kubernetes_version, ''): # don't prompt here because there is another prompt below? if instance.provisioning_state == "Succeeded": logger.warning("The cluster is already on version %s and is not in a failed state. No operations " @@ -2505,7 +2505,7 @@ def aks_agentpool_upgrade(cmd, client, resource_group_name, cluster_name, instance = client.get(resource_group_name, cluster_name, nodepool_name) - if kubernetes_version == '' or instance.orchestrator_version == kubernetes_version: + if kubernetes_version in ('', instance.orchestrator_version): msg = "The new kubernetes version is the same as the current kubernetes version." if instance.provisioning_state == "Succeeded": msg = "The cluster is already on version {} and is not in a failed state. No operations will occur when upgrading to the same version if the cluster is not in a failed state.".format(instance.orchestrator_version) diff --git a/src/azure-cli/azure/cli/command_modules/acs/maintenanceconfiguration.py b/src/azure-cli/azure/cli/command_modules/acs/maintenanceconfiguration.py index e032bb4ce71..c9ef0c83625 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/maintenanceconfiguration.py +++ b/src/azure-cli/azure/cli/command_modules/acs/maintenanceconfiguration.py @@ -48,7 +48,7 @@ def getMaintenanceConfiguration(cmd, raw_parameters): config_name = raw_parameters.get("config_name") if config_name == CONST_DEFAULT_CONFIGURATION_NAME: return constructDefaultMaintenanceConfiguration(cmd, raw_parameters) - if config_name == CONST_AUTOUPGRADE_CONFIGURATION_NAME or config_name == CONST_NODEOSUPGRADE_CONFIGURATION_NAME: + if config_name in (CONST_AUTOUPGRADE_CONFIGURATION_NAME, CONST_NODEOSUPGRADE_CONFIGURATION_NAME): return constructDedicatedMaintenanceConfiguration(cmd, raw_parameters) raise InvalidArgumentValueError('--config-name must be one of default, aksManagedAutoUpgradeSchedule or aksManagedNodeOSUpgradeSchedule, not {}'.format(config_name)) diff --git a/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py b/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py index 8372e4ef9b4..fc234614bcd 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py +++ b/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py @@ -2176,10 +2176,7 @@ def _get_outbound_type( # dynamic completion if ( - not read_from_mc and - outbound_type != CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY and - outbound_type != CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY and - outbound_type != CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING + not read_from_mc and outbound_type not in (CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY, CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY, CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING) ): outbound_type = CONST_OUTBOUND_TYPE_LOAD_BALANCER diff --git a/src/azure-cli/azure/cli/command_modules/ams/operations/transform.py b/src/azure-cli/azure/cli/command_modules/ams/operations/transform.py index b1e61a89890..b7d47ebad09 100644 --- a/src/azure-cli/azure/cli/command_modules/ams/operations/transform.py +++ b/src/azure-cli/azure/cli/command_modules/ams/operations/transform.py @@ -82,7 +82,7 @@ def validate_arguments(preset, insights_to_extract, audio_language, resolution): if insights_to_extract and preset != 'VideoAnalyzer': raise CLIError("insights-to-extract argument only works with VideoAnalyzer preset type.") - if audio_language and preset != 'VideoAnalyzer' and preset != 'AudioAnalyzer': + if audio_language and preset not in ('VideoAnalyzer', 'AudioAnalyzer'): raise CLIError("audio-language argument only works with VideoAnalyzer or AudioAnalyzer preset types.") if resolution and preset != 'FaceDetector': diff --git a/src/azure-cli/azure/cli/command_modules/appconfig/_kv_helpers.py b/src/azure-cli/azure/cli/command_modules/appconfig/_kv_helpers.py index a799f90056d..a320c20717f 100644 --- a/src/azure-cli/azure/cli/command_modules/appconfig/_kv_helpers.py +++ b/src/azure-cli/azure/cli/command_modules/appconfig/_kv_helpers.py @@ -51,7 +51,7 @@ def validate_import_key(key): if not isinstance(key, str): logger.warning("Ignoring invalid key '%s'. Key must be a string.", key) return False - if key == '.' or key == '..' or '%' in key: + if key in (".", "..") or "%" in key: logger.warning("Ignoring invalid key '%s'. Key cannot be a '.' or '..', or contain the '%%' character.", key) return False if key.startswith(FeatureFlagConstants.FEATURE_FLAG_PREFIX): diff --git a/src/azure-cli/azure/cli/command_modules/appconfig/_validators.py b/src/azure-cli/azure/cli/command_modules/appconfig/_validators.py index 0877a5b6367..60570652003 100644 --- a/src/azure-cli/azure/cli/command_modules/appconfig/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/appconfig/_validators.py @@ -244,7 +244,7 @@ def validate_key(namespace): raise RequiredArgumentMissingError("Key cannot be empty.") input_key = str(namespace.key).lower() - if input_key == '.' or input_key == '..' or '%' in input_key: + if input_key in ('.', '..') or '%' in input_key: raise InvalidArgumentValueError("Key is invalid. Key cannot be a '.' or '..', or contain the '%' character.") diff --git a/src/azure-cli/azure/cli/command_modules/appservice/_validators.py b/src/azure-cli/azure/cli/command_modules/appservice/_validators.py index a3b8ed826a3..7e0a699fa7b 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/_validators.py @@ -482,7 +482,7 @@ def _validate_ase_is_v3(ase): def _validate_ase_not_ilb(ase): - if (ase.internal_load_balancing_mode != 0) and (ase.internal_load_balancing_mode != "None"): + if ase.internal_load_balancing_mode not in (0, "None"): raise ValidationError("Internal Load Balancer (ILB) App Service Environments not supported") 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 558d3e83851..7dd7e3b803a 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/custom.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/custom.py @@ -1323,8 +1323,7 @@ def setter(webapp): webapp.identity.user_assigned_identities = None if remove_local_identity: webapp.identity.type = (IdentityType.none - if webapp.identity.type == IdentityType.system_assigned or - webapp.identity.type == IdentityType.none + if webapp.identity.type in (IdentityType.system_assigned, IdentityType.none) else IdentityType.user_assigned) if webapp.identity.type not in [IdentityType.none, IdentityType.system_assigned]: @@ -7119,7 +7118,7 @@ def _make_onedeploy_request(params): # check the status of deployment # pylint: disable=too-many-nested-blocks - if response.status_code == 202 or response.status_code == 200: + if response.status_code in (202, 200): response_body = None if poll_async_deployment_for_debugging: if params.track_status is not None and params.track_status: @@ -7290,8 +7289,7 @@ def _verify_hostname_binding(cmd, resource_group_name, name, hostname, slot=None verified_hostname_found = False for hostname_binding in hostname_bindings: binding_name = hostname_binding.name.split('/')[-1] - if binding_name.lower() == hostname and (hostname_binding.host_name_type == 'Verified' or - hostname_binding.host_name_type == 'Managed'): + if binding_name.lower() == hostname and (hostname_binding.host_name_type in ('Verified', 'Managed')): verified_hostname_found = True return verified_hostname_found diff --git a/src/azure-cli/azure/cli/command_modules/appservice/static_sites.py b/src/azure-cli/azure/cli/command_modules/appservice/static_sites.py index 14644d9a731..622ac0c5c89 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/static_sites.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/static_sites.py @@ -242,8 +242,7 @@ def setter(staticsite): staticsite.identity.user_assigned_identities = None if remove_local_identity: staticsite.identity.type = (IdentityType.none - if staticsite.identity.type == IdentityType.system_assigned or - staticsite.identity.type == IdentityType.none + if staticsite.identity.type in (IdentityType.system_assigned, IdentityType.none) else IdentityType.user_assigned) if staticsite.identity.type not in [IdentityType.none, IdentityType.system_assigned]: 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 c639e437349..98209ac6d32 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 @@ -149,7 +149,7 @@ def pre_operations(self): user_assigned_identities = {} for identity in args.user_assigned_identities: user_assigned_identities[identity.to_serialized_data()] = {} - if args.identity_type == 'UserAssigned' or args.identity_type == 'SystemAssigned, UserAssigned': + if args.identity_type in ('UserAssigned', 'SystemAssigned, UserAssigned'): args.identity = { 'type': args.identity_type, 'userAssignedIdentities': user_assigned_identities @@ -200,7 +200,7 @@ def pre_operations(self): user_assigned_identities = {} for identity in args.user_assigned_identities: user_assigned_identities[identity.to_serialized_data()] = {} - if args.identity_type == 'UserAssigned' or args.identity_type == 'SystemAssigned, UserAssigned': + if args.identity_type in ('UserAssigned', 'SystemAssigned, UserAssigned'): args.identity = { 'type': args.identity_type, 'userAssignedIdentities': user_assigned_identities diff --git a/src/azure-cli/azure/cli/command_modules/cdn/custom/custom_cdn.py b/src/azure-cli/azure/cli/command_modules/cdn/custom/custom_cdn.py index d09f181b9df..00bd9f964d2 100644 --- a/src/azure-cli/azure/cli/command_modules/cdn/custom/custom_cdn.py +++ b/src/azure-cli/azure/cli/command_modules/cdn/custom/custom_cdn.py @@ -1135,7 +1135,7 @@ def post_operations(self): user_assigned_identities = {} for identity in args.user_assigned_identities: user_assigned_identities[identity.to_serialized_data()] = {} - if args.identity_type == 'UserAssigned' or args.identity_type == 'SystemAssigned, UserAssigned': + if args.identity_type in ("UserAssigned", "SystemAssigned, UserAssigned"): identity = { 'type': args.identity_type, 'userAssignedIdentities': user_assigned_identities diff --git a/src/azure-cli/azure/cli/command_modules/container/custom.py b/src/azure-cli/azure/cli/command_modules/container/custom.py index a4c9f4fa6bf..8ce767da4a5 100644 --- a/src/azure-cli/azure/cli/command_modules/container/custom.py +++ b/src/azure-cli/azure/cli/command_modules/container/custom.py @@ -547,7 +547,7 @@ def _get_subnet_id(cmd, location, resource_group_name, vnet, vnet_address_prefix "resource_group": resource_group_name }) except HttpResponseError as ex: - if ex.error.code == "NotFound" or ex.error.code == "ResourceNotFound": + if ex.error.code in ('NotFound', 'ResourceNotFound'): subnet = None else: raise @@ -580,7 +580,7 @@ def _get_subnet_id(cmd, location, resource_group_name, vnet, vnet_address_prefix "resource_group": resource_group_name }) except HttpResponseError as ex: - if ex.error.code == "NotFound" or ex.error.code == "ResourceNotFound": + if ex.error.code in ('NotFound', 'ResourceNotFound'): vnet = None else: raise @@ -1176,7 +1176,7 @@ def _is_container_terminated(client, resource_group_name, name, container_name): # If a container group is terminated, assume the container is also terminated. if container_group.instance_view and container_group.instance_view.state: - if container_group.instance_view.state == 'Succeeded' or container_group.instance_view.state == 'Failed': + if container_group.instance_view.state in ('Succeeded', 'Failed'): return True # If the restart policy is Always, assume the container will be restarted. diff --git a/src/azure-cli/azure/cli/command_modules/containerapp/_utils.py b/src/azure-cli/azure/cli/command_modules/containerapp/_utils.py index 22ea0ab0cc8..e8b03e308ce 100644 --- a/src/azure-cli/azure/cli/command_modules/containerapp/_utils.py +++ b/src/azure-cli/azure/cli/command_modules/containerapp/_utils.py @@ -1218,7 +1218,7 @@ def generate_randomized_cert_name(thumbprint, prefix, initial="rg"): from random import randint cert_name = "{}-{}-{}-{:04}".format(prefix[:14], initial[:14], thumbprint[:4].lower(), randint(0, 9999)) for c in cert_name: - if not (c.isalnum() or c == '-' or c == '.'): + if not (c.isalnum() or c in ('-', '.')): cert_name = cert_name.replace(c, '-') return cert_name.lower() diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/_validators.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/_validators.py index 5bc1ab06ae0..292c7b8f650 100644 --- a/src/azure-cli/azure/cli/command_modules/cosmosdb/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/_validators.py @@ -455,7 +455,7 @@ def _validate_included_paths_in_cep(partition_key_path, includedPaths, policyFor raise InvalidArgumentValueError("Invalid encryptionType included in Client Encryption Policy. " "encryptionType cannot be null or empty.") - if (encryptionType != "Deterministic" and encryptionType != "Randomized"): + if (encryptionType not in ('Deterministic', 'Randomized')): raise InvalidArgumentValueError(f"Invalid Encryption Type {encryptionType} used. " "Supported types are Deterministic or Randomized.") diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py index 7b8e747e143..8037b7d3509 100644 --- a/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py @@ -1572,7 +1572,7 @@ def cli_cosmosdb_identity_assign(client, new_user_identities = [x for x in identities if x != SYSTEM_ID] only_enabling_system = enable_system and len(new_user_identities) == 0 - system_already_added = existing.identity.type == ResourceIdentityType.system_assigned or existing.identity.type == ResourceIdentityType.system_assigned_user_assigned + system_already_added = existing.identity.type in (ResourceIdentityType.system_assigned, ResourceIdentityType.system_assigned_user_assigned) if only_enabling_system and system_already_added: return existing.identity @@ -2766,7 +2766,7 @@ def process_restorable_databases(restorable_databases, database_name): if resource.operation_type == "Delete" and latest_database_delete_time < event_timestamp: latest_database_delete_time = event_timestamp - if (resource.operation_type == "Create" or resource.operation_type == "Recreate") and latest_database_create_or_recreate_time < event_timestamp: + if (resource.operation_type in ("Create", "Recreate")) and latest_database_create_or_recreate_time < event_timestamp: latest_database_create_or_recreate_time = event_timestamp if database_rid is None: @@ -2793,7 +2793,7 @@ def process_restorable_collections(restorable_collections, collection_name, data if resource.operation_type == "Delete" and latest_collection_delete_time < event_timestamp: latest_collection_delete_time = event_timestamp - if (resource.operation_type == "Create" or resource.operation_type == "Recreate") and latest_collection_create_or_recreate_time < event_timestamp: + if (resource.operation_type in ("Create", "Recreate")) and latest_collection_create_or_recreate_time < event_timestamp: latest_collection_create_or_recreate_time = event_timestamp if collection_rid is None: diff --git a/src/azure-cli/azure/cli/command_modules/eventhubs/action.py b/src/azure-cli/azure/cli/command_modules/eventhubs/action.py index a93d7379049..d1b844630af 100644 --- a/src/azure-cli/azure/cli/command_modules/eventhubs/action.py +++ b/src/azure-cli/azure/cli/command_modules/eventhubs/action.py @@ -64,7 +64,7 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use if k == 'id': VirtualNetworkList["id"] = v elif k == 'ignore-missing-endpoint': - if v == "true" or v == "True" or v == "TRUE": + if v in ('true', 'True', 'TRUE'): VirtualNetworkList["ignore_missing_endpoint"] = True else: VirtualNetworkList["ignore_missing_endpoint"] = False 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..2023332bad7 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 @@ -431,7 +431,7 @@ def metric(self): self.state = 71 self._errHandler.sync(self) _alt = 1 - while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + while _alt not in (2, ATN.INVALID_ALT_NUMBER): if _alt == 1: self.state = 70 _la = self._input.LA(1) @@ -688,7 +688,7 @@ def dimensions(self): self.state = 93 self._errHandler.sync(self) _la = self._input.LA(1) - while _la==11 or _la==17: + while _la in (11, 17): self.state = 88 self.dim_separator() self.state = 89 @@ -796,7 +796,7 @@ def dim_separator(self): self.enterOuterAlt(localctx, 1) self.state = 100 _la = self._input.LA(1) - if not(_la==11 or _la==17): + if not(_la in (11, 17)): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -845,7 +845,7 @@ def dim_operator(self): self.enterOuterAlt(localctx, 1) self.state = 103 _la = self._input.LA(1) - if not(_la==13 or _la==14): + if not(_la in (13, 14)): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -897,7 +897,7 @@ def dim_val_separator(self): self.enterOuterAlt(localctx, 1) self.state = 106 _la = self._input.LA(1) - if not(_la==11 or _la==20): + if not(_la in (11, 20)): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -1005,7 +1005,7 @@ def dim_values(self): self.state = 118 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input,6,self._ctx) - while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + while _alt not in (2, ATN.INVALID_ALT_NUMBER): if _alt==1: self.state = 113 self.dim_val_separator() @@ -1073,7 +1073,7 @@ def dim_value(self): self.state = 122 self._errHandler.sync(self) _alt = 1 - while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + while _alt not in (2, ATN.INVALID_ALT_NUMBER): if _alt == 1: self.state = 121 _la = self._input.LA(1) 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..14bc90e00b2 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 @@ -267,7 +267,7 @@ def expression(self): self.state = 58 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input,0,self._ctx) - while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + while _alt not in (2, ATN.INVALID_ALT_NUMBER): if _alt==1: self.state = 53 self.namespace() @@ -316,7 +316,7 @@ def expression(self): self.state = 78 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input,3,self._ctx) - while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + while _alt not in (2, ATN.INVALID_ALT_NUMBER): if _alt==1: self.state = 74 self.match(MetricAlertConditionParser.WHITESPACE) @@ -444,7 +444,7 @@ def namespace(self): self.state = 95 self._errHandler.sync(self) _alt = 1 - while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + while _alt not in (2, ATN.INVALID_ALT_NUMBER): if _alt == 1: self.state = 94 _la = self._input.LA(1) @@ -754,7 +754,7 @@ def dynamics(self): self.state = 123 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input,8,self._ctx) - while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + while _alt not in (2, ATN.INVALID_ALT_NUMBER): if _alt==1: self.state = 117 self.match(MetricAlertConditionParser.WHITESPACE) @@ -1165,7 +1165,7 @@ def dimensions(self): self.state = 155 self._errHandler.sync(self) _la = self._input.LA(1) - while _la==8 or _la==16: + while _la in (8, 16): self.state = 150 self.dim_separator() self.state = 151 @@ -1273,7 +1273,7 @@ def dim_separator(self): self.enterOuterAlt(localctx, 1) self.state = 162 _la = self._input.LA(1) - if not(_la==8 or _la==16): + if not(_la in (8, 16)): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -1328,7 +1328,7 @@ def dim_operator(self): self.enterOuterAlt(localctx, 1) self.state = 165 _la = self._input.LA(1) - if not(_la==17 or _la==18): + if not(_la in (17, 18)): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -1380,7 +1380,7 @@ def dim_val_separator(self): self.enterOuterAlt(localctx, 1) self.state = 168 _la = self._input.LA(1) - if not(_la==8 or _la==19): + if not(_la in (8, 19)): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -1488,7 +1488,7 @@ def dim_values(self): self.state = 180 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input,11,self._ctx) - while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + while _alt not in (2, ATN.INVALID_ALT_NUMBER): if _alt==1: self.state = 175 self.dim_val_separator() @@ -1556,7 +1556,7 @@ def dim_value(self): self.state = 184 self._errHandler.sync(self) _alt = 1 - while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + while _alt not in (2, ATN.INVALID_ALT_NUMBER): if _alt == 1: self.state = 183 _la = self._input.LA(1) diff --git a/src/azure-cli/azure/cli/command_modules/mysql/_validators.py b/src/azure-cli/azure/cli/command_modules/mysql/_validators.py index 5d180a4cd13..076a117c457 100644 --- a/src/azure-cli/azure/cli/command_modules/mysql/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/mysql/_validators.py @@ -358,8 +358,8 @@ def ip_address_validator(ns): def public_access_validator(ns): if ns.public_access: val = ns.public_access.lower() - if not (ns.public_access == 'Disabled' or ns.public_access == 'Enabled' or - val == 'all' or val == 'none' or (len(val.split('-')) == 1 and _validate_ip(val)) or + if not (ns.public_access in ('Disabled', 'Enabled') or + val in ('all', 'none') or (len(val.split('-')) == 1 and _validate_ip(val)) or (len(val.split('-')) == 2 and _validate_ip(val))): raise CLIError('incorrect usage: --public-access. ' 'Acceptable values are \'Disabled\', \'Enabled\', \'all\', \'none\',\'\' and ' diff --git a/src/azure-cli/azure/cli/command_modules/network/azure_stack/custom.py b/src/azure-cli/azure/cli/command_modules/network/azure_stack/custom.py index 668e07f2e46..0e5683aaa8a 100644 --- a/src/azure-cli/azure/cli/command_modules/network/azure_stack/custom.py +++ b/src/azure-cli/azure/cli/command_modules/network/azure_stack/custom.py @@ -231,13 +231,13 @@ def export_zone(cmd, resource_group_name, zone_name, file_name=None): # pylint: if record_type not in zone_obj[record_set_name]: zone_obj[record_set_name][record_type] = [] # Checking for alias record - if (record_type == 'a' or record_type == 'aaaa' or record_type == 'cname') and record_set.target_resource.id: + if (record_type in ('a', 'aaaa', 'cname')) and record_set.target_resource.id: target_resource_id = record_set.target_resource.id record_obj.update({'target-resource-id': record_type.upper() + " " + target_resource_id}) record_type = 'alias' if record_type not in zone_obj[record_set_name]: zone_obj[record_set_name][record_type] = [] - elif record_type == 'aaaa' or record_type == 'a': + elif record_type in ('aaaa', 'a'): record_obj.update({'ip': ''}) elif record_type == 'cname': record_obj.update({'alias': ''}) 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 0f62ec867f3..897f124d195 100644 --- a/src/azure-cli/azure/cli/command_modules/network/custom.py +++ b/src/azure-cli/azure/cli/command_modules/network/custom.py @@ -2630,13 +2630,13 @@ def export_zone(cmd, resource_group_name, zone_name, file_name=None): # pylint: if record_type not in zone_obj[record_set_name]: zone_obj[record_set_name][record_type] = [] # Checking for alias record - if (record_type == 'a' or record_type == 'aaaa' or record_type == 'cname') and record_set["target_resource"].get("id", ""): + if (record_type in ("a", "aaaa", "cname")) and record_set["target_resource"].get("id", ""): target_resource_id = record_set["target_resource"]["id"] record_obj.update({'target-resource-id': record_type.upper() + " " + target_resource_id}) record_type = 'alias' if record_type not in zone_obj[record_set_name]: zone_obj[record_set_name][record_type] = [] - elif record_type == 'aaaa' or record_type == 'a': + elif record_type in ("aaaa", "a"): record_obj.update({'ip': ''}) elif record_type == 'cname': record_obj.update({'alias': ''}) diff --git a/src/azure-cli/azure/cli/command_modules/rdbms/_params.py b/src/azure-cli/azure/cli/command_modules/rdbms/_params.py index 7fe3501277f..755d76ece29 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/_params.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/_params.py @@ -979,7 +979,7 @@ def _flexible_server_params(command_group): c.extra('connection_id', options_list=['--id'], required=False, help='The ID of the private endpoint connection associated with the Server. ' 'If specified --server-name/-s and --name/-n, this should be omitted.') - if scope == "approve" or scope == "reject": + if scope in ('approve', 'reject'): c.argument('description', help='Comments for {} operation.'.format(scope), required=True) for scope in ['list', 'show']: 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 d823772e368..4ced84c4b90 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 @@ -1506,7 +1506,7 @@ def _update_local_contexts(cmd, server_name, resource_group_name, database_name, def _get_pg_replica_zone(availabilityZones, sourceServerZone, replicaZone): preferredZone = 'none' for _index, zone in enumerate(availabilityZones): - if zone != sourceServerZone and zone != 'none': + if zone not in (sourceServerZone, 'none'): preferredZone = zone if not preferredZone: diff --git a/src/azure-cli/azure/cli/command_modules/rdbms/tests/latest/test_rdbms_commands.py b/src/azure-cli/azure/cli/command_modules/rdbms/tests/latest/test_rdbms_commands.py index 8542cce9e11..99720bf7348 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/tests/latest/test_rdbms_commands.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/tests/latest/test_rdbms_commands.py @@ -557,7 +557,7 @@ def _test_db_mgmt(self, resource_group, server, database_engine): checks=JMESPathCheck('type(@)', 'array')) def _test_configuration_mgmt(self, resource_group, server, database_engine): - if database_engine == 'mysql' or database_engine == 'mariadb': + if database_engine in ('mysql', 'mariadb'): config_name = 'log_slow_admin_statements' default_value = 'OFF' new_value = 'ON' @@ -594,7 +594,7 @@ def _test_configuration_mgmt(self, resource_group, server, database_engine): checks=[JMESPathCheck('type(@)', 'array')]) def _test_log_file_mgmt(self, resource_group, server, database_engine): - if database_engine == 'mysql' or database_engine == 'mariadb': + if database_engine in ('mysql', 'mariadb'): config_name = 'slow_query_log' new_value = 'ON' 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 a519bdc60f3..4f56a412123 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/validators.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/validators.py @@ -550,8 +550,8 @@ def ip_address_validator(ns): def public_access_validator(ns): if ns.public_access: val = ns.public_access.lower() - if not (ns.public_access == 'Disabled' or ns.public_access == 'Enabled' or - val == 'all' or val == 'none' or (len(val.split('-')) == 1 and _validate_ip(val)) or + if not (ns.public_access in ('Disabled', 'Enabled') or + val in ('all', 'none') or (len(val.split('-')) == 1 and _validate_ip(val)) or (len(val.split('-')) == 2 and _validate_ip(val))): raise CLIError('incorrect usage: --public-access. ' 'Acceptable values are \'Disabled\', \'Enabled\', \'all\', \'none\',\'\' and ' diff --git a/src/azure-cli/azure/cli/command_modules/redis/custom.py b/src/azure-cli/azure/cli/command_modules/redis/custom.py index e0b28bf3eaa..5d41f81d3f9 100644 --- a/src/azure-cli/azure/cli/command_modules/redis/custom.py +++ b/src/azure-cli/azure/cli/command_modules/redis/custom.py @@ -252,8 +252,8 @@ def cli_redis_identity_remove(client, resource_group_name, cache_name, mi_system type=ManagedServiceIdentityType.NONE.value) if identity is None: return none_identity - if (identity.type == ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED.value or - identity.type == ManagedServiceIdentityType.SYSTEM_ASSIGNED.value): + if identity.type in (ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED.value, + ManagedServiceIdentityType.SYSTEM_ASSIGNED.value): system_assigned = True if mi_system_assigned is not None: system_assigned = None 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 5eb051f3191..10c517aae4d 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/custom.py +++ b/src/azure-cli/azure/cli/command_modules/resource/custom.py @@ -1572,7 +1572,7 @@ def _load_file_string_or_uri(file_or_string_or_uri, name, required=True): raise CLIError('--{} is required'.format(name)) return None url = urlparse(file_or_string_or_uri) - if url.scheme == 'http' or url.scheme == 'https' or url.scheme == 'file': + if url.scheme in ('http', 'https', 'file'): response = urlopen(file_or_string_or_uri) reader = codecs.getreader('utf-8') result = json.load(reader(response)) diff --git a/src/azure-cli/azure/cli/command_modules/role/custom.py b/src/azure-cli/azure/cli/command_modules/role/custom.py index a2b38a0904e..ac0494a4cba 100644 --- a/src/azure-cli/azure/cli/command_modules/role/custom.py +++ b/src/azure-cli/azure/cli/command_modules/role/custom.py @@ -1818,7 +1818,7 @@ def _match_odata_type(odata_type, user_input): user_input = user_input.lower() # Full match "#microsoft.graph.servicePrincipal" == "#microsoft.graph.servicePrincipal" # Partial match "#microsoft.graph.servicePrincipal" ~= "servicePrincipal" - return odata_type == user_input or odata_type.split('.')[-1] == user_input + return user_input in (odata_type, odata_type.split('.')[-1]) def _open(location): diff --git a/src/azure-cli/azure/cli/command_modules/servicebus/action.py b/src/azure-cli/azure/cli/command_modules/servicebus/action.py index 4bb38216392..fb4e36d7ff9 100644 --- a/src/azure-cli/azure/cli/command_modules/servicebus/action.py +++ b/src/azure-cli/azure/cli/command_modules/servicebus/action.py @@ -62,7 +62,7 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use if k == 'id': VirtualNetworkList["id"] = v elif k == 'ignore-missing-endpoint': - if v == "true" or v == "True" or v == "TRUE": + if v in ('true', 'True', 'TRUE'): VirtualNetworkList["ignore_missing_endpoint"] = True else: VirtualNetworkList["ignore_missing_endpoint"] = False 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 34a7f451ed1..6f8815c7fc7 100644 --- a/src/azure-cli/azure/cli/command_modules/sql/custom.py +++ b/src/azure-cli/azure/cli/command_modules/sql/custom.py @@ -442,8 +442,7 @@ def _get_service_principal_object_from_type(servicePrincipalType): servicePrincipalResult = None if (servicePrincipalType is not None and - (servicePrincipalType == ServicePrincipalType.system_assigned.value or - servicePrincipalType == ServicePrincipalType.none.value)): + servicePrincipalType in (ServicePrincipalType.system_assigned.value, ServicePrincipalType.none.value)): servicePrincipalResult = ServicePrincipal(type=servicePrincipalType) return servicePrincipalResult diff --git a/src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py b/src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py index c00a98596e4..b12ee8973ee 100644 --- a/src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py +++ b/src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py @@ -143,7 +143,7 @@ def create_resource(self, name, **kwargs): if self.minimalTlsVersion: template += f" --minimal-tls-version {self.minimalTlsVersion}" - if self.identityType == ResourceIdType.system_assigned_user_assigned.value or self.identityType == ResourceIdType.user_assigned.value: + if self.identityType in (ResourceIdType.system_assigned_user_assigned.value, ResourceIdType.user_assigned.value): template += f" --assign-identity --user-assigned-identity-id {self.userAssignedIdentityId} --identity-type {self.identityType} --pid {self.pid}" if self.identityType == ResourceIdType.system_assigned.value: diff --git a/src/azure-cli/azure/cli/command_modules/storage/operations/table.py b/src/azure-cli/azure/cli/command_modules/storage/operations/table.py index b9c6dade5a1..a6240554469 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/operations/table.py +++ b/src/azure-cli/azure/cli/command_modules/storage/operations/table.py @@ -75,7 +75,7 @@ def insert_entity(client, entity, if_exists='fail'): return client.create_entity(entity) except ResourceExistsError: raise ResourceExistsError("The specified entity already exists.") - if if_exists == 'merge' or if_exists == 'replace': + if if_exists in ('merge', 'replace'): return client.upsert_entity(entity, mode=if_exists) from knack.util import CLIError raise CLIError("Unrecognized value '{}' for --if-exists".format(if_exists)) diff --git a/src/azure-cli/azure/cli/command_modules/storage/storage_url_helpers.py b/src/azure-cli/azure/cli/command_modules/storage/storage_url_helpers.py index 8cf7c4f0fe7..f1e38c936bb 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/storage_url_helpers.py +++ b/src/azure-cli/azure/cli/command_modules/storage/storage_url_helpers.py @@ -25,7 +25,7 @@ def __init__(self, cloud, moniker): from urllib.parse import urlparse url = urlparse(moniker) - self._is_url = (url.scheme == 'http' or url.scheme == 'https') + self._is_url = (url.scheme in ('http', 'https')) if not self._is_url: return diff --git a/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_blob_copy_scenarios.py b/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_blob_copy_scenarios.py index 77590974d6b..67a2e270b71 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_blob_copy_scenarios.py +++ b/src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_blob_copy_scenarios.py @@ -197,7 +197,7 @@ def test_storage_blob_copy_destination_blob_type(self, resource_group, account1, src_blob_name, '--destination-blob-type '+dst_type if dst_type != '' else '') self.storage_cmd('storage blob show -c {} -n {}', account1_info, target_container, 'dst'+dst_type). \ assert_with_checks([JMESPathCheck('properties.blobType', - dst_type if (dst_type != '' and dst_type != 'Detect') + dst_type if (dst_type not in ('', 'Detect')) else src_type)]) src_type = 'AppendBlob' @@ -210,7 +210,7 @@ def test_storage_blob_copy_destination_blob_type(self, resource_group, account1, src_blob_name, '--destination-blob-type ' + dst_type if dst_type != '' else '') self.storage_cmd('storage blob show -c {} -n {}', account1_info, target_container, 'dst2' + dst_type). \ assert_with_checks([JMESPathCheck('properties.blobType', - dst_type if (dst_type != '' and dst_type != 'Detect') + dst_type if (dst_type not in ('', 'Detect')) else src_type)]) src_type = 'PageBlob' @@ -223,7 +223,7 @@ def test_storage_blob_copy_destination_blob_type(self, resource_group, account1, src_blob_name, '--destination-blob-type ' + dst_type if dst_type != '' else '') self.storage_cmd('storage blob show -c {} -n {}', account1_info, target_container, 'dst3' + dst_type). \ assert_with_checks([JMESPathCheck('properties.blobType', - dst_type if (dst_type != '' and dst_type != 'Detect') + dst_type if (dst_type not in ('', 'Detect')) else src_type)]) # tier @@ -273,7 +273,7 @@ def test_storage_blob_copy_destination_blob_type(self, resource_group, account1, self.storage_cmd('storage blob show -c {} -n {}', account2_info, target_container_different_account, 'dst' + dst_type).\ assert_with_checks([JMESPathCheck('properties.blobType', - dst_type if (dst_type != '' and dst_type != 'Detect') + dst_type if (dst_type not in ('', 'Detect')) else src_type)]) src_type = 'AppendBlob' @@ -287,7 +287,7 @@ def test_storage_blob_copy_destination_blob_type(self, resource_group, account1, '--destination-blob-type ' + dst_type if dst_type != '' else '') self.storage_cmd('storage blob show -c {} -n {}', account2_info, target_container_different_account, 'dst2' + dst_type). \ assert_with_checks([JMESPathCheck('properties.blobType', - dst_type if (dst_type != '' and dst_type != 'Detect') + dst_type if (dst_type not in ('', 'Detect')) else src_type)]) src_type = 'PageBlob' @@ -301,7 +301,7 @@ def test_storage_blob_copy_destination_blob_type(self, resource_group, account1, '--destination-blob-type ' + dst_type if dst_type != '' else '') self.storage_cmd('storage blob show -c {} -n {}', account2_info, target_container_different_account, 'dst3' + dst_type). \ assert_with_checks([JMESPathCheck('properties.blobType', - dst_type if (dst_type != '' and dst_type != 'Detect') + dst_type if (dst_type not in ('', 'Detect')) else src_type)]) # tier @@ -431,12 +431,12 @@ def test_storage_blob_copy_batch_destination_blob_type(self, resource_group, acc blob_name = 'src' + src_type self.storage_cmd('storage blob show -c {} -n {}', account1_info, dst_container, blob_name). \ assert_with_checks([JMESPathCheck('properties.blobType', - dst_type if (dst_type != '' and dst_type != 'Detect') + dst_type if (dst_type not in ('', 'Detect')) else src_type)]) self.storage_cmd('storage blob show -c {} -n {}', account2_info, dst_container_different_account, blob_name). \ assert_with_checks([JMESPathCheck('properties.blobType', - dst_type if (dst_type != '' and dst_type != 'Detect') + dst_type if (dst_type not in ('', 'Detect')) else src_type)]) # tier diff --git a/src/azure-cli/azure/cli/command_modules/storage/util.py b/src/azure-cli/azure/cli/command_modules/storage/util.py index abb05045c60..692d37b76fd 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/util.py +++ b/src/azure-cli/azure/cli/command_modules/storage/util.py @@ -288,7 +288,7 @@ def _get_prefix(p): return p pattern_start = len(p) for index, ch in enumerate(p): - if ch == '*' or ch == '?' or ch == '[': + if ch in ('*', '?', '['): pattern_start = index break if pattern_start == len(p): diff --git a/src/azure-cli/azure/cli/command_modules/synapse/manual/operations/spark.py b/src/azure-cli/azure/cli/command_modules/synapse/manual/operations/spark.py index af16c364bd1..ed1ee5e7b65 100644 --- a/src/azure-cli/azure/cli/command_modules/synapse/manual/operations/spark.py +++ b/src/azure-cli/azure/cli/command_modules/synapse/manual/operations/spark.py @@ -39,7 +39,7 @@ def create_spark_batch_job(cmd, workspace_name, spark_pool_name, job_name, main_ class_name = main_class_name final_command_line_arguments = [] if main_class_name is None: - if language == SparkBatchLanguage.SparkDotNet or language == SparkBatchLanguage.Spark: + if language in (SparkBatchLanguage.SparkDotNet, SparkBatchLanguage.Spark): raise CLIError('Cannot perform the requested operation because main class name' ' is not provided. Please specify --main-class-name for Spark job or ' ' .NET Spark job') 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 a0d185e9232..15e39f018c1 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -5269,7 +5269,7 @@ def execute_query_for_vm(cmd, client, resource_group_name, vm_name, analytics_qu workspace = None extension_resources = vm.resources or [] for resource in extension_resources: - if resource.name == "MicrosoftMonitoringAgent" or resource.name == "OmsAgentForLinux": + if resource.name in ('MicrosoftMonitoringAgent', 'OmsAgentForLinux'): workspace = resource.settings.get('workspaceId', None) if workspace is None: raise CLIError('Cannot find the corresponding log analytics workspace. ' diff --git a/tools/automation/cli_linter/rules/help_rules.py b/tools/automation/cli_linter/rules/help_rules.py index 926d5fc6b4d..dd089e062d6 100644 --- a/tools/automation/cli_linter/rules/help_rules.py +++ b/tools/automation/cli_linter/rules/help_rules.py @@ -138,7 +138,7 @@ def _extract_commands_from_example(example_text): for line in lines: for ch in line: if quote is None: - if ch == '"' or ch == "'": + if ch in ('"', "'"): quote = ch elif ch == quote: quote = None diff --git a/tools/automation/tests/__init__.py b/tools/automation/tests/__init__.py index ccc89c690ad..1dde2a0f318 100644 --- a/tools/automation/tests/__init__.py +++ b/tools/automation/tests/__init__.py @@ -271,7 +271,7 @@ def discover_tests(args): module_data = {} for mod in all_modules: mod_name = mod[1] - if mod_name == 'core' or mod_name == 'telemetry': + if mod_name in ('core', 'telemetry'): mod_data = { 'filepath': os.path.join(mod[0].path, mod_name, 'tests'), 'base_path': 'azure.cli.{}.tests'.format(mod_name),