diff --git a/pylintrc b/pylintrc index 89640c4ea40..bb4952224dc 100644 --- a/pylintrc +++ b/pylintrc @@ -42,7 +42,6 @@ disable= consider-using-enumerate, # These rules were added in Pylint >= 2.12, disable them to avoid making retroactive change missing-timeout, - unnecessary-dunder-call, # These rules were added in Pylint >= 3.2 possibly-used-before-assignment, diff --git a/scripts/live_test/generate_index.py b/scripts/live_test/generate_index.py index 100eeadeb62..97b47f1fa74 100644 --- a/scripts/live_test/generate_index.py +++ b/scripts/live_test/generate_index.py @@ -177,7 +177,7 @@ def render(data, container, container_url, testdata, USER_REPO, USER_BRANCH, COM # elif 'sequential' in name: # display_name = 'sequential' try: - html = requests.get(url).content.__str__() + html = requests.get(url).text pattern = re.compile('\\d+ tests ran in') match = pattern.search(html) number = match.group().split()[0] diff --git a/src/azure-cli-core/azure/cli/core/telemetry.py b/src/azure-cli-core/azure/cli/core/telemetry.py index bf90048b589..002efba6435 100644 --- a/src/azure-cli-core/azure/cli/core/telemetry.py +++ b/src/azure-cli-core/azure/cli/core/telemetry.py @@ -316,7 +316,7 @@ def flush(): save(get_config_dir(), _session.generate_payload()) # reset session fields, retaining correlation id and application - _session.__init__(correlation_id=_session.correlation_id, application=_session.application) + _session.__init__(correlation_id=_session.correlation_id, application=_session.application) # pylint: disable=unnecessary-dunder-call @_user_agrees_to_telemetry diff --git a/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_staticapp_commands_thru_mock.py b/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_staticapp_commands_thru_mock.py index fd3cb4443a0..343cbc1c7d4 100644 --- a/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_staticapp_commands_thru_mock.py +++ b/src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_staticapp_commands_thru_mock.py @@ -618,7 +618,7 @@ def test_list_staticsite_secrets(self): self.staticapp_client.list_static_site_secrets.assert_called_once_with(resource_group_name=self.rg1, name=self.name1) from ast import literal_eval - self.assertEqual(literal_eval(secret.__str__())["properties"]["apiKey"], "key") + self.assertEqual(literal_eval(str(secret))["properties"]["apiKey"], "key") def test_staticsite_identity_assign(self): @@ -656,7 +656,7 @@ def test_reset_staticsite_api_key(self): self.staticapp_client.reset_static_site_api_key.assert_called_once() from ast import literal_eval - reset_envelope = literal_eval(self.staticapp_client.reset_static_site_api_key.call_args[1]["reset_properties_envelope"].__str__()) + reset_envelope = literal_eval(str(self.staticapp_client.reset_static_site_api_key.call_args[1]["reset_properties_envelope"])) self.assertEqual(reset_envelope["repository_token"], self.token1) @mock.patch("azure.cli.command_modules.appservice.static_sites.show_app") diff --git a/src/azure-cli/azure/cli/command_modules/botservice/tests/latest/test_bot_commands.py b/src/azure-cli/azure/cli/command_modules/botservice/tests/latest/test_bot_commands.py index f6a75305c48..72db3ead8cc 100644 --- a/src/azure-cli/azure/cli/command_modules/botservice/tests/latest/test_bot_commands.py +++ b/src/azure-cli/azure/cli/command_modules/botservice/tests/latest/test_bot_commands.py @@ -481,7 +481,7 @@ def test_botservice_create_should_raise_error_for_invalid_app_id_args(self, reso self.cmd('az bot create -g {rg} -n {botname} --appid {numbers_id} --app-type MultiTenant') raise AssertionError() except CLIError as cli_error: - assert cli_error.__str__() == expected_error + assert str(cli_error) == expected_error except AssertionError: raise AssertionError('should have thrown an error for appid that is not valid GUID.') @@ -489,7 +489,7 @@ def test_botservice_create_should_raise_error_for_invalid_app_id_args(self, reso self.cmd('az bot create -g {rg} -n {botname} --appid {short_app_id} --app-type MultiTenant') raise AssertionError() except CLIError as cli_error: - assert cli_error.__str__() == expected_error + assert str(cli_error) == expected_error except AssertionError: raise AssertionError('should have thrown an error for appid that is not valid GUID.') @@ -497,7 +497,7 @@ def test_botservice_create_should_raise_error_for_invalid_app_id_args(self, reso self.cmd('az bot create -g {rg} -n {botname} --appid "" --app-type MultiTenant') raise AssertionError() except CLIError as cli_error: - assert cli_error.__str__() == expected_error + assert str(cli_error) == expected_error except AssertionError: raise AssertionError('should have thrown an error for appid that is not valid GUID.') @@ -527,7 +527,7 @@ def test_botservice_should_throw_if_name_is_unavailable(self, resource_group): 'az bot create -g {rg2} -n {botname} -d {description} -e {endpoint} --appid {app_id} --app-type MultiTenant') raise AssertionError() except CLIError as cli_error: - assert cli_error.__str__().startswith('Unable to create bot.\nReason: ') + assert str(cli_error).startswith('Unable to create bot.\nReason: ') except AssertionError: raise AssertionError('should have thrown an error for unavailable name.') @@ -780,8 +780,8 @@ def test_botservice_prepare_deploy_should_fail_if_code_dir_doesnt_exist(self): prepare_webapp_deploy(language, code_dir, proj_file_path) raise Exception("'az bot prepare-publish' should have failed with nonexistent --code-dir value") except CLIError as cli_error: - print(cli_error.__str__()) - assert cli_error.__str__() == 'Provided --code-dir value (does_not_exist) does not exist' + print(str(cli_error)) + assert str(cli_error) == 'Provided --code-dir value (does_not_exist) does not exist' except Exception as error: raise error @@ -794,7 +794,7 @@ def test_botservice_prepare_deploy_javascript_should_fail_with_proj_file_path(se prepare_webapp_deploy(language, code_dir, proj_file_path) raise Exception("'az bot prepare-publish ' should have failed with --proj-file-path") except CLIError as cli_error: - assert cli_error.__str__() == '--proj-file-path should not be passed in if language is not Csharp' + assert str(cli_error) == '--proj-file-path should not be passed in if language is not Csharp' except Exception as error: raise error @@ -820,7 +820,7 @@ def test_botservice_prepare_deploy_typescript_should_fail_with_proj_file_path(se prepare_webapp_deploy(language, code_dir, proj_file_path) raise Exception("'az bot prepare-publish --lang Typescript' should have failed with --proj-file-path") except CLIError as cli_error: - assert cli_error.__str__() == '--proj-file-path should not be passed in if language is not Csharp' + assert str(cli_error) == '--proj-file-path should not be passed in if language is not Csharp' def test_botservice_prepare_deploy_typescript(self): code_dir = 'node_bot_typescript' @@ -880,7 +880,7 @@ def test_botservice_prepare_deploy_csharp_no_proj_file(self): prepare_webapp_deploy(language, code_dir, proj_file_path) raise Exception("'az bot prepare-publish ' should have failed with no --proj-file-path") except CLIError as cli_error: - assert cli_error.__str__() == '--proj-file-path must be provided if language is Csharp' + assert str(cli_error) == '--proj-file-path must be provided if language is Csharp' def test_botservice_prepare_deploy_csharp_fail_if_deployment_file_exists(self): code_dir = 'csharp_bot_deployment' @@ -899,7 +899,7 @@ def test_botservice_prepare_deploy_csharp_fail_if_deployment_file_exists(self): shutil.rmtree(code_dir) except CLIError as cli_error: shutil.rmtree(code_dir) - assert cli_error.__str__() == '.deployment found in csharp_bot_deployment\nPlease delete this .deployment before ' \ + assert str(cli_error) == '.deployment found in csharp_bot_deployment\nPlease delete this .deployment before ' \ 'calling "az bot prepare-deploy"' except Exception as error: shutil.rmtree(code_dir) @@ -921,7 +921,7 @@ def test_botservice_prepare_deploy_javascript_fail_if_web_config_exists(self): shutil.rmtree(code_dir) except CLIError as cli_error: shutil.rmtree(code_dir) - assert cli_error.__str__() == 'web.config found in node_bot_web_config\nPlease delete this web.config before ' \ + assert str(cli_error) == 'web.config found in node_bot_web_config\nPlease delete this web.config before ' \ 'calling "az bot prepare-deploy"' except Exception as error: shutil.rmtree(code_dir) 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 64e499267e3..89c07ab3a5b 100644 --- a/src/azure-cli/azure/cli/command_modules/containerapp/_utils.py +++ b/src/azure-cli/azure/cli/command_modules/containerapp/_utils.py @@ -1584,7 +1584,7 @@ def set_managed_identity(cmd, resource_group_name, containerapp_def, system_assi containerapp_def["identity"] = {} containerapp_def["identity"]["type"] = "None" - if assign_system_identity and containerapp_def["identity"]["type"].__contains__("SystemAssigned"): + if assign_system_identity and "SystemAssigned" in containerapp_def["identity"]["type"]: logger.warning("System identity is already assigned to containerapp") # Assign correct type diff --git a/src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_utils.py b/src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_utils.py index 7d849f6ccd2..16641e3e569 100644 --- a/src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_utils.py +++ b/src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_utils.py @@ -229,7 +229,7 @@ def test_load_cert_file(self): try: blob, thumbprint = load_cert_file(pfx_file, testpassword) except CLIInternalError as e: - self.assertTrue(e.error_msg.error_msg.__contains__('Invalid password or PKCS12 data')) + self.assertIn('Invalid password or PKCS12 data', e.error_msg.error_msg) self.assertEqual('', thumbprint) pfx_file = os.path.join(TEST_DIR, 'data', 'cert2.pfx') diff --git a/src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/utils.py b/src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/utils.py index 1c92c379406..d3d7471de18 100644 --- a/src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/utils.py +++ b/src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/utils.py @@ -17,7 +17,7 @@ def prepare_containerapp_env_for_app_e2e_tests(test_cls): try: managed_env = test_cls.cmd('containerapp env show -g {} -n {}'.format(rg_name, env_name)).get_output_in_json() except CLIInternalError as e: - if e.error_msg.__contains__('ResourceGroupNotFound') or e.error_msg.__contains__('ResourceNotFound'): + if 'ResourceGroupNotFound' in e.error_msg or 'ResourceNotFound' in e.error_msg: test_cls.cmd(f'group create -n {rg_name}') test_cls.cmd(f'containerapp env create -g {rg_name} -n {env_name} --logs-destination none') managed_env = test_cls.cmd('containerapp env show -g {} -n {}'.format(rg_name, env_name)).get_output_in_json() diff --git a/src/azure-cli/azure/cli/command_modules/resource/_validators.py b/src/azure-cli/azure/cli/command_modules/resource/_validators.py index 2f0969509be..02dc593dccd 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/resource/_validators.py @@ -61,7 +61,7 @@ def _validate_deployment_name_with_template_specs(namespace): namespace.template_spec = namespace.template_spec.strip("\"") if not is_valid_resource_id(namespace.template_spec): raise CLIError('--template-spec is not a valid resource ID.') - if namespace.template_spec.__contains__("versions") is False: + if 'versions' not in namespace.template_spec: raise CLIError('Please enter a valid template spec version ID.') template_filename = parse_resource_id(namespace.template_spec).get('resource_name') if template_filename: