Fix H201 violations and re-enable gating
H201 got stricter in hacking 0.9, so fix new violations and re-enable gating. Change-Id: Ie79b04bc1ae2d4784318c19661584d02b7bee088 Implements: blueprint reduce-flake8-ignore-rules
This commit is contained in:
parent
a7dd2bb0e4
commit
4876f70b02
@ -153,7 +153,7 @@ def upgrade(migrate_engine):
|
||||
for index, table in enumerate(tables):
|
||||
try:
|
||||
table.create()
|
||||
except:
|
||||
except Exception:
|
||||
# If an error occurs, drop all tables created so far to return
|
||||
# to the previously existing state.
|
||||
meta.drop_all(tables=tables[:index])
|
||||
|
@ -32,6 +32,6 @@ def downgrade(migrate_engine):
|
||||
|
||||
try:
|
||||
resource.c.id.alter(sqlalchemy.Integer, primary_key=True)
|
||||
except:
|
||||
except Exception:
|
||||
#XXX: since there is no way to downgrade just passing
|
||||
pass
|
||||
|
@ -34,7 +34,7 @@ def downgrade(migrate_engine):
|
||||
|
||||
try:
|
||||
event.c.id.alter(type=sqlalchemy.Integer, primary_key=True)
|
||||
except:
|
||||
except Exception:
|
||||
# NOTE(pafuent): since there is no way to downgrade just passing
|
||||
# The same is did in 018_resource_id_uuid.py
|
||||
migrate_util.log.warning(_('If you really want to downgrade to this '
|
||||
|
@ -411,7 +411,7 @@ class Resource(object):
|
||||
failure = exception.ResourceFailure(ex, self, action)
|
||||
self.state_set(action, self.FAILED, six.text_type(failure))
|
||||
raise failure
|
||||
except:
|
||||
except: # noqa
|
||||
with excutils.save_and_reraise_exception():
|
||||
try:
|
||||
self.state_set(action, self.FAILED,
|
||||
@ -694,7 +694,7 @@ class Resource(object):
|
||||
failure = exception.ResourceFailure(ex, self, self.action)
|
||||
self.state_set(action, self.FAILED, six.text_type(failure))
|
||||
raise failure
|
||||
except:
|
||||
except: # noqa
|
||||
with excutils.save_and_reraise_exception():
|
||||
try:
|
||||
self.state_set(action, self.FAILED,
|
||||
|
@ -185,7 +185,7 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
|
||||
userdata_parts = None
|
||||
try:
|
||||
userdata_parts = email.message_from_string(userdata)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if userdata_parts and userdata_parts.is_multipart():
|
||||
for part in userdata_parts.get_payload():
|
||||
|
@ -265,7 +265,7 @@ def wrappertask(task):
|
||||
except GeneratorExit as ex:
|
||||
subtask.close()
|
||||
raise ex
|
||||
except:
|
||||
except: # noqa
|
||||
try:
|
||||
step = subtask.throw(*sys.exc_info())
|
||||
except StopIteration:
|
||||
@ -280,7 +280,7 @@ def wrappertask(task):
|
||||
except GeneratorExit as ex:
|
||||
parent.close()
|
||||
raise ex
|
||||
except:
|
||||
except: # noqa
|
||||
subtask = parent.throw(*sys.exc_info())
|
||||
else:
|
||||
subtask = next(parent)
|
||||
@ -340,7 +340,7 @@ class DependencyTaskGroup(object):
|
||||
if not self.aggregate_exceptions:
|
||||
raise
|
||||
raised_exceptions.append(e)
|
||||
except:
|
||||
except: # noqa
|
||||
with excutils.save_and_reraise_exception():
|
||||
for r in self._runners.itervalues():
|
||||
r.cancel()
|
||||
@ -466,7 +466,7 @@ class PollingTaskGroup(object):
|
||||
yield
|
||||
runners = list(itertools.dropwhile(lambda r: r.step(),
|
||||
runners))
|
||||
except:
|
||||
except: # noqa
|
||||
with excutils.save_and_reraise_exception():
|
||||
for r in runners:
|
||||
r.cancel()
|
||||
|
@ -131,7 +131,7 @@ class StackLock(object):
|
||||
try:
|
||||
self.acquire()
|
||||
yield
|
||||
except:
|
||||
except: # noqa
|
||||
with excutils.save_and_reraise_exception():
|
||||
self.release(stack_id)
|
||||
|
||||
@ -146,7 +146,7 @@ class StackLock(object):
|
||||
try:
|
||||
result = self.try_acquire()
|
||||
yield result
|
||||
except:
|
||||
except: # noqa
|
||||
if result is None: # Lock was successfully acquired
|
||||
with excutils.save_and_reraise_exception():
|
||||
self.release(stack_id)
|
||||
|
@ -295,7 +295,7 @@ def stack_context(stack_name, create_res=True):
|
||||
create_stack()
|
||||
try:
|
||||
test_fn(test_case, *args, **kwargs)
|
||||
except:
|
||||
except Exception:
|
||||
exc_class, exc_val, exc_tb = sys.exc_info()
|
||||
try:
|
||||
delete_stack()
|
||||
|
@ -63,7 +63,7 @@ class NovaServerGroupTest(HeatTestCase):
|
||||
try:
|
||||
sg = sg_template['resources']['ServerGroup']
|
||||
del sg['properties']['name']
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self._init_template(sg_template)
|
||||
name = 'test'
|
||||
|
@ -32,6 +32,9 @@ class StackLockTest(HeatTestCase):
|
||||
self.stack.action = "CREATE"
|
||||
self.engine_id = stack_lock.StackLock.generate_engine_id()
|
||||
|
||||
class TestThreadLockException(Exception):
|
||||
pass
|
||||
|
||||
def test_successful_acquire_new_lock(self):
|
||||
self.m.StubOutWithMock(db_api, "stack_lock_create")
|
||||
db_api.stack_lock_create(
|
||||
@ -168,12 +171,13 @@ class StackLockTest(HeatTestCase):
|
||||
db_api.stack_lock_create = mock.Mock(return_value=None)
|
||||
db_api.stack_lock_release = mock.Mock(return_value=None)
|
||||
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
||||
try:
|
||||
|
||||
def check_thread_lock():
|
||||
with slock.thread_lock(self.stack.id):
|
||||
self.assertEqual(1, db_api.stack_lock_create.call_count)
|
||||
raise Exception
|
||||
except:
|
||||
self.assertEqual(1, db_api.stack_lock_release.call_count)
|
||||
raise self.TestThreadLockException
|
||||
self.assertRaises(self.TestThreadLockException, check_thread_lock)
|
||||
self.assertEqual(1, db_api.stack_lock_release.call_count)
|
||||
|
||||
def test_thread_lock_context_mgr_no_exception(self):
|
||||
db_api.stack_lock_create = mock.Mock(return_value=None)
|
||||
@ -187,12 +191,13 @@ class StackLockTest(HeatTestCase):
|
||||
db_api.stack_lock_create = mock.Mock(return_value=None)
|
||||
db_api.stack_lock_release = mock.Mock(return_value=None)
|
||||
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
||||
try:
|
||||
|
||||
def check_thread_lock():
|
||||
with slock.try_thread_lock(self.stack.id):
|
||||
self.assertEqual(1, db_api.stack_lock_create.call_count)
|
||||
raise Exception
|
||||
except:
|
||||
self.assertEqual(1, db_api.stack_lock_release.call_count)
|
||||
raise self.TestThreadLockException
|
||||
self.assertRaises(self.TestThreadLockException, check_thread_lock)
|
||||
self.assertEqual(1, db_api.stack_lock_release.call_count)
|
||||
|
||||
def test_try_thread_lock_context_mgr_no_exception(self):
|
||||
db_api.stack_lock_create = mock.Mock(return_value=None)
|
||||
@ -206,9 +211,10 @@ class StackLockTest(HeatTestCase):
|
||||
db_api.stack_lock_create = mock.Mock(return_value=1234)
|
||||
db_api.stack_lock_release = mock.Mock(return_value=None)
|
||||
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
||||
try:
|
||||
|
||||
def check_thread_lock():
|
||||
with slock.try_thread_lock(self.stack.id):
|
||||
self.assertEqual(1, db_api.stack_lock_create.call_count)
|
||||
raise Exception
|
||||
except:
|
||||
assert not db_api.stack_lock_release.called
|
||||
raise self.TestThreadLockException
|
||||
self.assertRaises(self.TestThreadLockException, check_thread_lock)
|
||||
assert not db_api.stack_lock_release.called
|
||||
|
3
tox.ini
3
tox.ini
@ -37,11 +37,10 @@ deps = -r{toxinidir}/requirements.txt
|
||||
commands = python setup.py build_sphinx
|
||||
|
||||
[flake8]
|
||||
# H201 no 'except:' at least use 'except Exception:'
|
||||
# H302 import only modules.'bla..' does not import a module
|
||||
# H404 multi line docstring should start with a summary
|
||||
# H803 no full stop at the end of the commit message
|
||||
ignore = H201,H302,H404,H803
|
||||
ignore = H302,H404,H803
|
||||
show-source = true
|
||||
builtins = _
|
||||
exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,tools,build
|
||||
|
Loading…
Reference in New Issue
Block a user