[Trivial]Remove unused variables

This is to remove unused variables and to use merging-isinstance.

Change-Id: I9d7121678a8b18a03b7b872526bfc74351560776
This commit is contained in:
zhufl 2020-11-19 14:39:04 +08:00
parent 805f2a070b
commit 3ead99814d
10 changed files with 25 additions and 26 deletions

View File

@ -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)

View File

@ -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')

View File

@ -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 "

View File

@ -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):

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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('//', '/')

View File

@ -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)

View File

@ -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)