Avoid using `len(x)` to check if x is empty

This cases are using `len()` to check if collection has items.
As collections have a boolean representation too, directly check
for true / false.

Change-Id: I1e552db99fbe6d33ad43bb710af924261dcebb46
changes/74/281374/1
Raildo Mascena 7 years ago
parent d32c7b0e7f
commit e5f91ce479

@ -43,7 +43,7 @@ class SchemaValidator(object):
except jsonschema.ValidationError as ex:
# NOTE: For whole OpenStack message consistency, this error
# message has been written in a format consistent with WSME.
if len(ex.path) > 0:
if ex.path:
# NOTE(lbragstad): Here we could think about using iter_errors
# as a method of providing invalid parameters back to the
# user.

@ -303,7 +303,7 @@ class OAuthControllerV3(controller.V3Controller):
body=context['query_string'],
headers=headers)
params = oauth1.extract_non_oauth_params(b)
if len(params) != 0:
if params:
msg = _('There should not be any non-oauth parameters')
raise exception.Unauthorized(message=msg)

@ -305,7 +305,7 @@ class CheckForLoggingIssues(BaseASTChecker):
return super(CheckForLoggingIssues, self).generic_visit(node)
# the call must have arguments
if not len(node.args):
if not node.args:
return super(CheckForLoggingIssues, self).generic_visit(node)
if method_name == 'debug':

Loading…
Cancel
Save