Merge "pylint: Address no-else-continue/no-else-raise warnings"
This commit is contained in:
commit
abcbb0dea8
@ -55,10 +55,6 @@ disable=
|
||||
duplicate-code,
|
||||
inconsistent-return-statements, # TODO
|
||||
interface-not-implemented,
|
||||
# Better to be fixed but too many hits :(
|
||||
no-else-continue, # TODO
|
||||
# Better to be fixed but too many hits :(
|
||||
no-else-raise, # TODO
|
||||
no-else-return,
|
||||
no-self-use,
|
||||
# python3 way: Let's do it once we have a consensus.
|
||||
|
@ -187,7 +187,7 @@ class Registry(object):
|
||||
"""
|
||||
if not inspect.isclass(cls):
|
||||
raise ValueError('Only classes may be registered.')
|
||||
elif not issubclass(cls, self._registerable_class):
|
||||
if not issubclass(cls, self._registerable_class):
|
||||
raise ValueError('Only %s classes or subclasses may be registered.'
|
||||
% self._registerable_class.__name__)
|
||||
|
||||
@ -233,11 +233,10 @@ class Registry(object):
|
||||
"slug": cls,
|
||||
"parent": parent,
|
||||
"name": self.slug})
|
||||
else:
|
||||
slug = getattr(cls, "slug", cls)
|
||||
raise NotRegistered('%(type)s with slug "%(slug)s" is not '
|
||||
'registered.' % {"type": class_name,
|
||||
"slug": slug})
|
||||
slug = getattr(cls, "slug", cls)
|
||||
raise NotRegistered('%(type)s with slug "%(slug)s" is not '
|
||||
'registered.' % {"type": class_name,
|
||||
"slug": slug})
|
||||
|
||||
|
||||
class Panel(HorizonComponent):
|
||||
@ -821,8 +820,7 @@ class Site(Registry, HorizonComponent):
|
||||
# If it's not callable and not a string, it's wrong.
|
||||
raise ValueError('The user_home setting must be either a string '
|
||||
'or a callable object (e.g. a function).')
|
||||
else:
|
||||
return self.get_absolute_url()
|
||||
return self.get_absolute_url()
|
||||
|
||||
def get_absolute_url(self):
|
||||
"""Returns the default URL for Horizon's URLconf.
|
||||
|
@ -76,8 +76,7 @@ class MultiTableMixin(object):
|
||||
cls_name = self.__class__.__name__
|
||||
raise NotImplementedError("You must define a %s method "
|
||||
"in %s." % (func_name, cls_name))
|
||||
else:
|
||||
return func
|
||||
return func
|
||||
|
||||
def assign_type_string(self, data, type_name, data_type):
|
||||
for datum in data:
|
||||
|
@ -344,7 +344,7 @@ class Step(object):
|
||||
# If it's callable we know the function exists and is valid
|
||||
self._handlers[key].append(possible_handler)
|
||||
continue
|
||||
elif not isinstance(possible_handler, str):
|
||||
if not isinstance(possible_handler, str):
|
||||
raise TypeError("Connection handlers must be either "
|
||||
"callables or strings.")
|
||||
bits = possible_handler.split(".")
|
||||
@ -789,7 +789,7 @@ class Workflow(html.HTMLElement, metaclass=WorkflowMetaclass):
|
||||
"""Registers a :class:`~horizon.workflows.Step` with the workflow."""
|
||||
if not inspect.isclass(step_class):
|
||||
raise ValueError('Only classes may be registered.')
|
||||
elif not issubclass(step_class, cls._registerable_class):
|
||||
if not issubclass(step_class, cls._registerable_class):
|
||||
raise ValueError('Only %s classes or subclasses may be registered.'
|
||||
% cls._registerable_class.__name__)
|
||||
if step_class in cls._cls_registry:
|
||||
@ -852,7 +852,7 @@ class Workflow(html.HTMLElement, metaclass=WorkflowMetaclass):
|
||||
data = step.action.handle(self.request, self.context)
|
||||
if data is True or data is None:
|
||||
continue
|
||||
elif data is False:
|
||||
if data is False:
|
||||
partial = True
|
||||
else:
|
||||
self.context = step.contribute(data or {}, self.context)
|
||||
|
@ -117,9 +117,9 @@ class DeleteDomainsAction(tables.DeleteAction):
|
||||
% domain.name
|
||||
messages.error(request, msg)
|
||||
raise keystoneclient_exceptions.ClientException(msg)
|
||||
else:
|
||||
LOG.info('Deleting domain "%s".', obj_id)
|
||||
api.keystone.domain_delete(request, obj_id)
|
||||
|
||||
LOG.info('Deleting domain "%s".', obj_id)
|
||||
api.keystone.domain_delete(request, obj_id)
|
||||
|
||||
|
||||
class DisableDomainsAction(tables.BatchAction):
|
||||
|
@ -246,11 +246,12 @@ class CreateImageForm(CreateParent):
|
||||
if not image_url and not image_file:
|
||||
msg = _("An image file or an external location must be specified.")
|
||||
if source_type == 'file':
|
||||
raise ValidationError({'image_file': [msg, ]})
|
||||
error_msg = {'image_file': [msg, ]}
|
||||
else:
|
||||
raise ValidationError({'image_url': [msg, ]})
|
||||
else:
|
||||
return data
|
||||
error_msg = {'image_url': [msg, ]}
|
||||
raise ValidationError(error_msg)
|
||||
|
||||
return data
|
||||
|
||||
def handle(self, request, data):
|
||||
meta = api.glance.create_image_metadata(data)
|
||||
|
@ -686,20 +686,20 @@ class CustomizeAction(workflows.Action):
|
||||
if upload_file._size > 16 * units.Ki: # 16kb
|
||||
msg = _('File exceeds maximum size (16kb)')
|
||||
raise forms.ValidationError(msg)
|
||||
else:
|
||||
script = upload_file.read()
|
||||
if script != "":
|
||||
try:
|
||||
if not isinstance(script, str):
|
||||
script = script.decode()
|
||||
normalize_newlines(script)
|
||||
except Exception as e:
|
||||
msg = _('There was a problem parsing the'
|
||||
' %(prefix)s: %(error)s')
|
||||
msg = msg % {'prefix': prefix,
|
||||
'error': e}
|
||||
raise forms.ValidationError(msg)
|
||||
return script
|
||||
|
||||
script = upload_file.read()
|
||||
if script != "":
|
||||
try:
|
||||
if not isinstance(script, str):
|
||||
script = script.decode()
|
||||
normalize_newlines(script)
|
||||
except Exception as e:
|
||||
msg = _('There was a problem parsing the'
|
||||
' %(prefix)s: %(error)s')
|
||||
msg = msg % {'prefix': prefix,
|
||||
'error': e}
|
||||
raise forms.ValidationError(msg)
|
||||
return script
|
||||
else:
|
||||
return None
|
||||
|
||||
|
@ -140,10 +140,9 @@ class CreateGroupView(forms.ModalFormView):
|
||||
usages['volumes']['quota']):
|
||||
raise ValueError(_('Unable to create group due to '
|
||||
'exceeding volume quota limit.'))
|
||||
else:
|
||||
context['numRequestedItems'] = num_volumes
|
||||
context['usages'] = usages
|
||||
|
||||
context['numRequestedItems'] = num_volumes
|
||||
context['usages'] = usages
|
||||
except ValueError as e:
|
||||
exceptions.handle(self.request, e.message)
|
||||
return None
|
||||
|
@ -207,10 +207,9 @@ class CreateSnapshotView(forms.ModalFormView):
|
||||
usages['snapshots']['quota']):
|
||||
raise ValueError(_('Unable to create snapshots due to '
|
||||
'exceeding snapshot quota limit.'))
|
||||
else:
|
||||
context['numRequestedItems'] = num_volumes
|
||||
context['usages'] = usages
|
||||
|
||||
context['numRequestedItems'] = num_volumes
|
||||
context['usages'] = usages
|
||||
except ValueError as e:
|
||||
exceptions.handle(self.request, e.message)
|
||||
return None
|
||||
@ -251,10 +250,9 @@ class CloneGroupView(forms.ModalFormView):
|
||||
usages['volumes']['quota']):
|
||||
raise ValueError(_('Unable to create group due to '
|
||||
'exceeding volume quota limit.'))
|
||||
else:
|
||||
context['numRequestedItems'] = num_volumes
|
||||
context['usages'] = usages
|
||||
|
||||
context['numRequestedItems'] = num_volumes
|
||||
context['usages'] = usages
|
||||
except ValueError as e:
|
||||
exceptions.handle(self.request, e.message)
|
||||
return None
|
||||
|
@ -420,7 +420,7 @@ class CreateForm(forms.SelfHandlingForm):
|
||||
params = {'req': data['size'],
|
||||
'avail': availableGB}
|
||||
raise ValidationError(error_message % params)
|
||||
elif availableVol <= 0:
|
||||
if availableVol <= 0:
|
||||
error_message = _('You are already using all of your available'
|
||||
' volumes.')
|
||||
raise ValidationError(error_message)
|
||||
|
Loading…
x
Reference in New Issue
Block a user