From 3ead99814d0fbac5e4f418f56d2854619ae40996 Mon Sep 17 00:00:00 2001 From: zhufl Date: Thu, 19 Nov 2020 14:39:04 +0800 Subject: [PATCH] [Trivial]Remove unused variables This is to remove unused variables and to use merging-isinstance. Change-Id: I9d7121678a8b18a03b7b872526bfc74351560776 --- tempest/cmd/account_generator.py | 2 +- tempest/lib/auth.py | 4 ++-- tempest/lib/cmd/check_uuid.py | 3 +-- tempest/lib/common/rest_client.py | 2 +- tempest/lib/common/utils/data_utils.py | 2 +- .../lib/services/identity/v3/groups_client.py | 2 +- .../identity/v3/inherited_roles_client.py | 8 +++---- .../identity/v3/oauth_token_client.py | 2 +- .../lib/services/identity/v3/roles_client.py | 24 +++++++++---------- .../lib/services/volume/v1/volumes_client.py | 2 +- 10 files changed, 25 insertions(+), 26 deletions(-) diff --git a/tempest/cmd/account_generator.py b/tempest/cmd/account_generator.py index ff552a1cbd..917262ed28 100755 --- a/tempest/cmd/account_generator.py +++ b/tempest/cmd/account_generator.py @@ -270,7 +270,7 @@ class TempestAccountGenerator(command.Command): config.CONF.set_config_path(parsed_args.config_file) setup_logging() resources = [] - for count in range(parsed_args.concurrency): + for _ in range(parsed_args.concurrency): # Use N different cred_providers to obtain different # sets of creds cred_provider = get_credential_provider(parsed_args) diff --git a/tempest/lib/auth.py b/tempest/lib/auth.py index 3fee489c15..7c279ab289 100644 --- a/tempest/lib/auth.py +++ b/tempest/lib/auth.py @@ -391,7 +391,7 @@ class KeystoneV2AuthProvider(KeystoneAuthProvider): """ if auth_data is None: auth_data = self.get_auth() - token, _auth_data = auth_data + _, _auth_data = auth_data service = filters.get('service') region = filters.get('region') name = filters.get('name') @@ -524,7 +524,7 @@ class KeystoneV3AuthProvider(KeystoneAuthProvider): """ if auth_data is None: auth_data = self.get_auth() - token, _auth_data = auth_data + _, _auth_data = auth_data service = filters.get('service') region = filters.get('region') name = filters.get('name') diff --git a/tempest/lib/cmd/check_uuid.py b/tempest/lib/cmd/check_uuid.py index b34066f8fb..ff09671dc2 100755 --- a/tempest/lib/cmd/check_uuid.py +++ b/tempest/lib/cmd/check_uuid.py @@ -225,8 +225,7 @@ class TestChecker(object): def _add_import_for_test_uuid(self, patcher, src_parsed, source_path): import_list = [node for node in src_parsed.body - if isinstance(node, ast.Import) or - isinstance(node, ast.ImportFrom)] + if isinstance(node, (ast.Import, ast.ImportFrom))] if not import_list: print("(WARNING) %s: The file is not valid as it does not contain " diff --git a/tempest/lib/common/rest_client.py b/tempest/lib/common/rest_client.py index 0513e90133..b47b511f6b 100644 --- a/tempest/lib/common/rest_client.py +++ b/tempest/lib/common/rest_client.py @@ -507,7 +507,7 @@ class RestClient(object): if not hasattr(body, "keys") or len(body.keys()) != 1: return body # Just return the "wrapped" element - first_key, first_item = six.next(six.iteritems(body)) + _, first_item = six.next(six.iteritems(body)) if isinstance(first_item, (dict, list)): return first_item except (ValueError, IndexError): diff --git a/tempest/lib/common/utils/data_utils.py b/tempest/lib/common/utils/data_utils.py index 7f946120ce..44b55eb556 100644 --- a/tempest/lib/common/utils/data_utils.py +++ b/tempest/lib/common/utils/data_utils.py @@ -129,7 +129,7 @@ def rand_infiniband_guid_address(): :rtype: string """ guid = [] - for i in range(8): + for _ in range(8): guid.append("%02x" % random.randint(0x00, 0xff)) return ':'.join(guid) diff --git a/tempest/lib/services/identity/v3/groups_client.py b/tempest/lib/services/identity/v3/groups_client.py index f823b219a8..2cfb24a032 100644 --- a/tempest/lib/services/identity/v3/groups_client.py +++ b/tempest/lib/services/identity/v3/groups_client.py @@ -110,6 +110,6 @@ class GroupsClient(rest_client.RestClient): def check_group_user_existence(self, group_id, user_id): """Check user in group.""" - resp, body = self.head('groups/%s/users/%s' % (group_id, user_id)) + resp, _ = self.head('groups/%s/users/%s' % (group_id, user_id)) self.expected_success(204, resp.status) return rest_client.ResponseBody(resp) diff --git a/tempest/lib/services/identity/v3/inherited_roles_client.py b/tempest/lib/services/identity/v3/inherited_roles_client.py index 3949437019..f937ed6125 100644 --- a/tempest/lib/services/identity/v3/inherited_roles_client.py +++ b/tempest/lib/services/identity/v3/inherited_roles_client.py @@ -51,7 +51,7 @@ class InheritedRolesClient(rest_client.RestClient): def check_user_inherited_project_role_on_domain( self, domain_id, user_id, role_id): """Checks whether a user has an inherited project role on a domain.""" - resp, body = self.head( + resp, _ = self.head( "OS-INHERIT/domains/%s/users/%s/roles/%s/inherited_to_projects" % (domain_id, user_id, role_id)) self.expected_success(204, resp.status) @@ -88,7 +88,7 @@ class InheritedRolesClient(rest_client.RestClient): def check_group_inherited_project_role_on_domain( self, domain_id, group_id, role_id): """Checks whether a group has an inherited project role on a domain.""" - resp, body = self.head( + resp, _ = self.head( "OS-INHERIT/domains/%s/groups/%s/roles/%s/inherited_to_projects" % (domain_id, group_id, role_id)) self.expected_success(204, resp.status) @@ -115,7 +115,7 @@ class InheritedRolesClient(rest_client.RestClient): def check_user_has_flag_on_inherited_to_project( self, project_id, user_id, role_id): """Check if user has an inherited project role on project""" - resp, body = self.head( + resp, _ = self.head( "OS-INHERIT/projects/%s/users/%s/roles/%s/inherited_to_projects" % (project_id, user_id, role_id)) self.expected_success(204, resp.status) @@ -142,7 +142,7 @@ class InheritedRolesClient(rest_client.RestClient): def check_group_has_flag_on_inherited_to_project( self, project_id, group_id, role_id): """Check if group has an inherited project role on project""" - resp, body = self.head( + resp, _ = self.head( "OS-INHERIT/projects/%s/groups/%s/roles/%s/inherited_to_projects" % (project_id, group_id, role_id)) self.expected_success(204, resp.status) diff --git a/tempest/lib/services/identity/v3/oauth_token_client.py b/tempest/lib/services/identity/v3/oauth_token_client.py index 6ca401be0f..722decad86 100644 --- a/tempest/lib/services/identity/v3/oauth_token_client.py +++ b/tempest/lib/services/identity/v3/oauth_token_client.py @@ -71,7 +71,7 @@ class OAUTHTokenClient(rest_client.RestClient): normalized_params = '&'.join(parameter_parts) # normalize_uri - scheme, netloc, path, params, query, fragment = urlparse.urlparse(uri) + scheme, netloc, path, params, _, _ = urlparse.urlparse(uri) scheme = scheme.lower() netloc = netloc.lower() path = path.replace('//', '/') diff --git a/tempest/lib/services/identity/v3/roles_client.py b/tempest/lib/services/identity/v3/roles_client.py index f9356be083..0d7593aa75 100644 --- a/tempest/lib/services/identity/v3/roles_client.py +++ b/tempest/lib/services/identity/v3/roles_client.py @@ -122,16 +122,16 @@ class RolesClient(rest_client.RestClient): def check_user_role_existence_on_project(self, project_id, user_id, role_id): """Check role of a user on a project.""" - resp, body = self.head('projects/%s/users/%s/roles/%s' % - (project_id, user_id, role_id)) + resp, _ = self.head('projects/%s/users/%s/roles/%s' % + (project_id, user_id, role_id)) self.expected_success(204, resp.status) return rest_client.ResponseBody(resp) def check_user_role_existence_on_domain(self, domain_id, user_id, role_id): """Check role of a user on a domain.""" - resp, body = self.head('domains/%s/users/%s/roles/%s' % - (domain_id, user_id, role_id)) + resp, _ = self.head('domains/%s/users/%s/roles/%s' % + (domain_id, user_id, role_id)) self.expected_success(204, resp.status) return rest_client.ResponseBody(resp) @@ -182,16 +182,16 @@ class RolesClient(rest_client.RestClient): def check_role_from_group_on_project_existence(self, project_id, group_id, role_id): """Check role of a group on a project.""" - resp, body = self.head('projects/%s/groups/%s/roles/%s' % - (project_id, group_id, role_id)) + resp, _ = self.head('projects/%s/groups/%s/roles/%s' % + (project_id, group_id, role_id)) self.expected_success(204, resp.status) return rest_client.ResponseBody(resp) def check_role_from_group_on_domain_existence(self, domain_id, group_id, role_id): """Check role of a group on a domain.""" - resp, body = self.head('domains/%s/groups/%s/roles/%s' % - (domain_id, group_id, role_id)) + resp, _ = self.head('domains/%s/groups/%s/roles/%s' % + (domain_id, group_id, role_id)) self.expected_success(204, resp.status) return rest_client.ResponseBody(resp) @@ -232,14 +232,14 @@ class RolesClient(rest_client.RestClient): def check_role_inference_rule(self, prior_role, implies_role): """Check a role inference rule.""" - resp, body = self.head('roles/%s/implies/%s' % - (prior_role, implies_role)) + resp, _ = self.head('roles/%s/implies/%s' % + (prior_role, implies_role)) self.expected_success(204, resp.status) return rest_client.ResponseBody(resp) def delete_role_inference_rule(self, prior_role, implies_role): """Delete a role inference rule.""" - resp, body = self.delete('roles/%s/implies/%s' % - (prior_role, implies_role)) + resp, _ = self.delete('roles/%s/implies/%s' % + (prior_role, implies_role)) self.expected_success(204, resp.status) return rest_client.ResponseBody(resp) diff --git a/tempest/lib/services/volume/v1/volumes_client.py b/tempest/lib/services/volume/v1/volumes_client.py index 4ed5eb12ca..2efb0da741 100644 --- a/tempest/lib/services/volume/v1/volumes_client.py +++ b/tempest/lib/services/volume/v1/volumes_client.py @@ -302,5 +302,5 @@ class VolumesClient(rest_client.RestClient): def retype_volume(self, volume_id, **kwargs): """Updates volume with new volume type.""" post_body = json.dumps({'os-retype': kwargs}) - resp, body = self.post('volumes/%s/action' % volume_id, post_body) + resp, _ = self.post('volumes/%s/action' % volume_id, post_body) self.expected_success(202, resp.status)