Switch to ignoring pep W503

Change-Id: I3fe7b6f33fa327a9584bbad3c695032bc0a3e54a
This commit is contained in:
Adrian Turjak 2018-12-02 01:01:51 +13:00
parent 496be1b077
commit d4ab292a6a
12 changed files with 50 additions and 54 deletions

View File

@ -109,10 +109,9 @@ class NewProjectAction(BaseAction, ProjectMixin, UserMixin):
# put user_id into action cache:
self.action.task.cache['user_id'] = user.id
self.set_cache('user_id', user.id)
self.add_note(("Existing user '%s' attached to project %s" +
" with roles: %s")
% (user.name, project_id,
default_roles))
self.add_note(
"Existing user '%s' attached to project %s with roles: %s"
% (user.name, project_id, default_roles))
def _submit(self, token_data):
"""
@ -221,9 +220,9 @@ class NewProjectWithUserAction(UserNameAction, ProjectMixin, UserMixin):
self.add_note("Project already created.")
else:
self.action.valid = (
self._validate_domain_id() and
self._validate_parent_project() and
self._validate_project_absent())
self._validate_domain_id()
and self._validate_parent_project()
and self._validate_project_absent())
self.action.save()
if not self.valid:
@ -302,10 +301,9 @@ class NewProjectWithUserAction(UserNameAction, ProjectMixin, UserMixin):
raise
self.set_cache('roles_granted', True)
self.add_note(("Existing user '%s' setup on project %s" +
" with roles: %s")
% (self.username, project_id,
default_roles))
self.add_note(
"Existing user '%s' setup on project %s with roles: %s"
% (self.username, project_id, default_roles))
elif self.action.state == "disabled":
user_id = self.get_cache('user_id')
if not user_id:
@ -349,10 +347,9 @@ class NewProjectWithUserAction(UserNameAction, ProjectMixin, UserMixin):
raise
self.set_cache('roles_granted', True)
self.add_note(("Existing user '%s' setup on project %s" +
" with roles: %s")
% (self.username, project_id,
default_roles))
self.add_note(
"Existing user '%s' setup on project %s with roles: %s"
% (self.username, project_id, default_roles))
def _submit(self, token_data):
"""

View File

@ -31,8 +31,7 @@ from adjutant.common.tests.fake_clients import (
@mock.patch('adjutant.common.user_store.IdentityManager',
FakeManager)
@mock.patch(
'adjutant.actions.v1.resources.' +
'openstack_clients.get_neutronclient',
'adjutant.actions.v1.resources.openstack_clients.get_neutronclient',
get_fake_neutron)
@mock.patch(
'adjutant.common.openstack_clients.get_neutronclient',

View File

@ -54,7 +54,7 @@ class NewUserAction(UserNameAction, ProjectMixin, UserMixin):
return True
if user.email != self.email:
self.add_note(
'Found matching username, but email did not match.' +
'Found matching username, but email did not match. '
'Reporting as invalid.')
return False

View File

@ -200,7 +200,7 @@ class UserDetail(tasks.TaskView):
if user:
return Response(
{'errors': [
'Revoking keystone users not implemented. ' +
'Revoking keystone users not implemented. '
'Try removing all roles instead.']},
status=501)
project_tasks = models.Task.objects.filter(

View File

@ -52,8 +52,8 @@ class TaskView(APIViewWithLogger):
self.task_type, settings.DEFAULT_TASK_SETTINGS)
actions = (
class_conf.get('default_actions', []) or
self.default_actions[:])
class_conf.get('default_actions', [])
or self.default_actions[:])
actions += class_conf.get('additional_actions', [])
@ -72,8 +72,8 @@ class TaskView(APIViewWithLogger):
action_serializer_list = []
action_names = (
class_conf.get('default_actions', []) or
self.default_actions[:])
class_conf.get('default_actions', [])
or self.default_actions[:])
action_names += class_conf.get('additional_actions', [])
# instantiate all action serializers and check validity
@ -369,8 +369,8 @@ class InviteUser(TaskView):
self.logger.info("(%s) - New AttachUser request." % timezone.now())
# Default project_id to the keystone user's project
if ('project_id' not in request.data or
request.data['project_id'] is None):
if ('project_id' not in request.data
or request.data['project_id'] is None):
request.data['project_id'] = request.keystone_user['project_id']
processed, status = self.process_actions(request)
@ -454,8 +454,8 @@ class EditUser(TaskView):
self.task_type, settings.DEFAULT_TASK_SETTINGS)
action_names = (
class_conf.get('default_actions', []) or
self.default_actions[:])
class_conf.get('default_actions', [])
or self.default_actions[:])
action_names += class_conf.get('additional_actions', [])
role_blacklist = class_conf.get('role_blacklist', [])

View File

@ -1548,7 +1548,7 @@ class AdminAPITests(APITestCase):
self.assertEqual(
response.json()['errors'],
["Error: Something went wrong on the server. " +
["Error: Something went wrong on the server. "
"It will be looked into shortly."])
new_task = Task.objects.all()[0]
@ -1558,6 +1558,6 @@ class AdminAPITests(APITestCase):
self.assertEqual(
new_notification.notes,
{'errors': [
"Error: KeyError('Forced key error.') while updating task. " +
"Error: KeyError('Forced key error.') while updating task. "
"See task itself for details."]})
self.assertEqual(new_notification.task, new_task)

View File

@ -352,7 +352,7 @@ class TaskViewTests(AdjutantAPITestCase):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(
response.json(),
{'errors': ['Cannot approve an invalid task. ' +
{'errors': ['Cannot approve an invalid task. '
'Update data and rerun pre_approve.']})
def test_new_project_existing_user(self):
@ -1394,8 +1394,8 @@ class TaskViewTests(AdjutantAPITestCase):
class_conf = settings.TASK_SETTINGS.get(
CreateProject.task_type, settings.DEFAULT_TASK_SETTINGS)
expected_action_names = (
class_conf.get('default_actions', []) or
CreateProject.default_actions[:])
class_conf.get('default_actions', [])
or CreateProject.default_actions[:])
expected_action_names += class_conf.get('additional_actions', [])
actions = new_task.actions
@ -1420,7 +1420,7 @@ class TaskViewTests(AdjutantAPITestCase):
self.assertEqual(
response.json(),
{'errors': ["Error: Something went wrong on the server. " +
{'errors': ["Error: Something went wrong on the server. "
"It will be looked into shortly."]})
new_task = Task.objects.all()[0]
@ -1430,6 +1430,6 @@ class TaskViewTests(AdjutantAPITestCase):
self.assertEqual(
new_notification.notes,
{'errors': [
"Error: KeyError('Forced key error.') while setting up " +
"Error: KeyError('Forced key error.') while setting up "
"task. See task itself for details."]})
self.assertEqual(new_notification.task, new_task)

View File

@ -74,8 +74,8 @@ def send_stage_email(task, email_conf, token=None):
if len(emails) > 1:
notes = {
'errors':
(("Error: Unable to send update, more than one email for" +
" task: %s") % task.uuid)
("Error: Unable to send update, more than one email for task: %s"
% task.uuid)
}
create_notification(task, notes, error=True)
return
@ -231,8 +231,8 @@ def parse_filters(func, *args, **kwargs):
except (ValueError, AttributeError):
return Response(
{'errors': [
("Filters incorrectly formatted. Required format: " +
"{'filters': {'fieldname': { 'operation': 'value'}}")
"Filters incorrectly formatted. Required format: "
"{'filters': {'fieldname': { 'operation': 'value'}}"
]},
status=400
)

View File

@ -50,15 +50,15 @@ class APIViewWithLogger(APIView):
timezone.now(), e, trace))
notes = {
'errors':
[("Error: %s(%s) %s. See task " +
"itself for details.") % (type(e).__name__, e, error_text)]
["Error: %s(%s) %s. See task itself for details."
% (type(e).__name__, e, error_text)]
}
create_notification(task, notes, error=True)
response_dict = {
'errors':
["Error: Something went wrong on the " +
"server. It will be looked into shortly."]
["Error: Something went wrong on the server. "
"It will be looked into shortly."]
}
if return_response:
return Response(response_dict, status=500)
@ -396,7 +396,7 @@ class TaskDetail(APIViewWithLogger):
if not valid:
return Response(
{'errors':
['Cannot approve an invalid task. ' +
['Cannot approve an invalid task. '
'Update data and rerun pre_approve.']},
status=400)
@ -689,8 +689,8 @@ class TokenDetail(APIViewWithLogger):
except KeyError:
errors[field] = ["This field is required.", ]
except TypeError:
errors = ["Improperly formated json. " +
"Should be a key-value object.", ]
errors = ["Improperly formated json. "
"Should be a key-value object."]
break
if errors:

View File

@ -201,8 +201,8 @@ class QuotaManager(object):
self._quota_updaters[service]
self.project_id = project_id
self.size_diff_threshold = (size_difference_threshold or
self.default_size_diff_threshold)
self.size_diff_threshold = (size_difference_threshold
or self.default_size_diff_threshold)
def get_current_region_quota(self, region_id):
current_quota = {}

View File

@ -186,8 +186,8 @@ class FakeManager(object):
domain = self._domain_from_id(domain)
global identity_cache
for user in identity_cache['users'].values():
if (user.name.lower() == name.lower() and
user.domain_id == domain.id):
if (user.name.lower() == name.lower()
and user.domain_id == domain.id):
return user
return None
@ -291,8 +291,8 @@ class FakeManager(object):
roles = []
for assignment in identity_cache['role_assignments']:
if (assignment.user['id'] == user.id and
assignment.scope['project']['id'] == project.id):
if (assignment.user['id'] == user.id
and assignment.scope['project']['id'] == project.id):
if (assignment.scope.get('OS-INHERIT:inherited_to') and not
inherited) or (
@ -364,8 +364,8 @@ class FakeManager(object):
domain = self._domain_from_id(domain)
global identity_cache
for project in identity_cache['projects'].values():
if (project.name.lower() == project_name.lower() and
project.domain_id == domain.id):
if (project.name.lower() == project_name.lower()
and project.domain_id == domain.id):
return project
return None

View File

@ -45,7 +45,7 @@ commands =
[flake8]
ignore = D100,D101,D102,D103,D104,D105,D200,D203,D202,D204,D205,D208,D400,D401
ignore = D100,D101,D102,D103,D104,D105,D200,D203,D202,D204,D205,D208,D400,D401,W503
show-source = true
builtins = _
exclude=.venv,venv,.env,env,.git,.tox,dist,doc,*lib/python*,*egg,adjutant/api/migrations/*,adjutant/actions/migrations