Enabling pylint no-else-return

Relevant logic was altered to comply with the rule
while preserving the function.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I8363336463dc170087924b2f7cc3fa56609f848e
This commit is contained in:
Jiri Podivin 2021-07-22 17:19:39 +02:00
parent aaea7d50ef
commit d7e8bfb053
12 changed files with 48 additions and 72 deletions

View File

@ -31,7 +31,6 @@ disable =
no-else-break,
no-else-continue,
no-else-raise,
no-else-return,
no-member,
no-self-use,
no-value-for-parameter,

View File

@ -90,7 +90,7 @@ class Command(command.Command):
'the --overcloud-ssh-key switch.'
)
return key
else:
return parsed_args.overcloud_ssh_key

View File

@ -1683,7 +1683,6 @@ class TestArgumentValidation(fakes.TestDeployOvercloud):
def is_dir(arg):
if arg == '/tmp/real_dir':
return True
else:
return False
patcher = mock.patch('os.path.isdir')

View File

@ -589,9 +589,8 @@ class TestDeployUndercloud(TestPluginV1):
def abs_path_stub(*args, **kwargs):
if 'notenv.yaml' in args:
return os.path.join(tht_render, 'notenv.yaml')
elif 'env.yaml' in args:
if 'env.yaml' in args:
return os.path.join(tht_render, 'env.yaml')
else:
return original_abs(*args, **kwargs)
# logic handled in _standalone_deploy

View File

@ -235,10 +235,8 @@ def playbook_verbosity(self):
if self.app.options.debug:
return 3
else:
if self.app_args.verbose_level <= 1:
return 0
else:
return self.app_args.verbose_level
@ -377,7 +375,6 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
if timeout and timeout > 0:
return ('Running Ansible playbook with timeout %sm: %s,' %
(timeout, playbook))
else:
return ('Running Ansible playbook: %s,' % playbook)
if not playbook_dir:
@ -736,11 +733,10 @@ def convert(data):
"""Recursively converts dictionary keys,values to strings."""
if isinstance(data, six.string_types):
return str(data)
elif isinstance(data, collectionsAbc.Mapping):
if isinstance(data, collectionsAbc.Mapping):
return dict(map(convert, six.iteritems(data)))
elif isinstance(data, collectionsAbc.Iterable):
if isinstance(data, collectionsAbc.Iterable):
return type(data)(map(convert, data))
else:
return data
@ -1019,7 +1015,6 @@ def get_endpoint(key, stack):
endpoint_map = get_endpoint_map(stack)
if endpoint_map:
return endpoint_map[key]['host']
else:
return get_service_ips(stack).get(key + 'Vip')
@ -1506,7 +1501,6 @@ def prompt_user_for_confirmation(message, logger, positive_response='y'):
if not sys.stdin.isatty():
logger.error(_('User interaction required, cannot confirm.'))
return False
else:
sys.stdout.write(message)
sys.stdout.flush()
prompt_response = sys.stdin.readline().lower()
@ -1564,7 +1558,6 @@ def replace_links_in_template(template_part, link_replacement):
if ((key == 'get_file' or key == 'type') and
isinstance(value, six.string_types)):
return link_replacement.get(value, value)
else:
return replace_links_in_template(value, link_replacement)
def replaced_list_value(value):
@ -1573,9 +1566,8 @@ def replace_links_in_template(template_part, link_replacement):
if isinstance(template_part, dict):
return {k: replaced_dict_value(k, v)
for k, v in six.iteritems(template_part)}
elif isinstance(template_part, list):
if isinstance(template_part, list):
return list(map(replaced_list_value, template_part))
else:
return template_part
@ -1680,7 +1672,7 @@ def get_tripleo_ansible_inventory(inventory_file=None,
with open(inventory_file, "r") as f:
inventory = f.read()
return inventory
else:
raise exceptions.InvalidConfiguration(_(
"Inventory file %s can not be found.") % inventory_file)
@ -2051,7 +2043,6 @@ def run_command_and_log(log, cmd, cwd=None, env=None, retcode_only=True):
break
proc.stdout.close()
return proc.wait()
else:
return proc
@ -2647,9 +2638,8 @@ def test_heat_api_port(heat_api_socket, host, port):
def get_heat_launcher(heat_type, *args, **kwargs):
if heat_type == 'native':
return heat_launcher.HeatNativeLauncher(*args, **kwargs)
elif heat_type == 'container':
if heat_type == 'container':
return heat_launcher.HeatContainerLauncher(*args, **kwargs)
else:
return heat_launcher.HeatPodLauncher(*args, **kwargs)

View File

@ -121,7 +121,7 @@ class BackupOvercloud(command.Command):
def _parse_extra_vars(self, raw_extra_vars):
if raw_extra_vars is None:
return {}
extra_vars = {}
elif os.path.exists(raw_extra_vars):
with open(raw_extra_vars, 'r') as fp:
extra_vars = yaml.safe_load(fp.read())

View File

@ -206,7 +206,7 @@ class FileImageClientAdapter(BaseClientAdapter):
if os.path.exists(path.replace("file://", "")):
return path
return None
elif prop == 'ramdisk_id':
if prop == 'ramdisk_id':
path = os.path.splitext(image.id)[0] + '.initrd'
if os.path.exists(path.replace("file://", "")):
return path
@ -267,14 +267,11 @@ class FileImageClientAdapter(BaseClientAdapter):
if self.updated is not None:
self.updated.append(dest_path)
return None
else:
print('Image "%s" already exists and can be updated'
' with --update-existing.' % dest_path)
return image
else:
print('Image "%s" is up-to-date, skipping.' % dest_path)
return image
else:
return None
def _upload_image(self, src_path, dest_path):
@ -337,14 +334,11 @@ class GlanceClientAdapter(BaseClientAdapter):
if self.updated is not None:
self.updated.append(image.id)
return None
else:
print('Image "%s" already exists and can be updated'
' with --update-existing.' % image_name)
return image
else:
print('Image "%s" is up-to-date, skipping.' % image_name)
return image
else:
return None
def _upload_image(self, name, data, properties=None, visibility='public',

View File

@ -188,7 +188,6 @@ class Deploy(command.Command):
if not parsed_args.networks_file:
return os.path.join(parsed_args.templates,
constants.STANDALONE_NETWORKS_FILE)
else:
return parsed_args.networks_file
def _get_primary_role_name(self, roles_file_path, templates):

View File

@ -155,11 +155,10 @@ class BackupUndercloud(command.Command):
def _parse_extra_vars(self, raw_extra_vars):
if raw_extra_vars is None:
return raw_extra_vars
extra_vars = None
elif os.path.exists(raw_extra_vars):
with open(raw_extra_vars, 'r') as fp:
extra_vars = yaml.safe_load(fp.read())
else:
try:
extra_vars = yaml.safe_load(raw_extra_vars)

View File

@ -122,7 +122,6 @@ def _get_unknown_instack_tags(env, src):
known_tags = set(INSTACK_NETCONF_MAPPING.keys())
if found_tags <= known_tags:
return (', ').join(found_tags - known_tags)
else:
return None

View File

@ -268,7 +268,6 @@ class Build(command.Command):
if content:
if tree:
return {tree: content}
else:
return content
return tree

View File

@ -44,7 +44,6 @@ def validate_nodes(clients, nodes_json):
validated_nodes = node_utils.validate_nodes(nodes_json)
if not validated_nodes:
return True
else:
raise exceptions.RegisterOrUpdateError(validated_nodes)