misc: fix no-else-raise pylint error (#62099)

This commit is contained in:
Lauréline Guérin 2022-03-18 15:43:23 +01:00
parent 40943abada
commit 50604f402f
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
5 changed files with 8 additions and 10 deletions

View File

@ -292,8 +292,7 @@ class SfrDmcGateway(SMSResource):
if 'success' not in json_data:
raise APIError('Bad JSON response')
elif not json_data['success']:
if not json_data['success']:
if not 'errorDetail' in json_data:
raise APIError('Bad JSON response')
else:
raise APIError(json_data['errorDetail'])
raise APIError(json_data['errorDetail'])

View File

@ -209,7 +209,7 @@ class Greco(BaseResource):
'HTTP Transport Error %s' % resp.status_code,
err_code='transport-error-%s' % resp.status_code,
)
elif resp.status_code == 500 and b'Fault' not in resp.content:
if resp.status_code == 500 and b'Fault' not in resp.content:
raise APIError('Error 500, not a SOAP Fault', err_code='transport-error-500')
return Reply(resp.status_code, resp.headers, resp.content)

View File

@ -82,7 +82,7 @@ def unflatten(d, separator=FLATTEN_SEPARATOR):
'incomplete array before %s in %s'
% (separator.join(map(str, path[: i + 1])), orig_key)
)
elif len(d) == key:
if len(d) == key:
d.append(new)
else:
new = d[key]

View File

@ -92,12 +92,11 @@ class MockedService:
def raise_error(self):
if self.error_class is WebFault:
raise self.error_class(mock.Mock(faulstring='Error %s raised' % self.error_class.__name__), None)
elif self.error_class is TransportError:
if self.error_class is TransportError:
raise self.error_class('connection error occured', None)
elif self.error_class is WebFaultHavingLatin1:
if self.error_class is WebFaultHavingLatin1:
raise WebFault(message='éêè')
else:
raise Exception('random error')
raise Exception('random error')
def return_response(self, *args, **kwargs):
return ReplyDataClass(**self.replydata)

View File

@ -226,7 +226,7 @@ def mock_http():
response = self.responses[idx]
if isinstance(response, Exception):
raise response
elif hasattr(response, '__call__'):
if hasattr(response, '__call__'):
response = response(url, request)
return response