From 0ee399a82835c2a57e015058025bc094def0d92f Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Tue, 25 Jun 2013 11:28:47 +0200 Subject: [PATCH] Start using Hacking Blacklist those warnings that occur frequently for followup patches. Fixup the rest and enable gating on those. Change-Id: I79f0ff1c16d9cb7f07cc99382c2a383e2fa532fc --- tox.ini | 2 +- trove/extensions/mysql/service.py | 2 +- trove/extensions/security_group/service.py | 2 +- trove/guestagent/db/models.py | 4 ++-- trove/tests/api/instances.py | 4 ++-- trove/tests/api/instances_actions.py | 2 +- trove/tests/api/mgmt/instances.py | 6 ++++-- trove/tests/unittests/guestagent/test_api.py | 4 ++-- trove/tests/unittests/guestagent/test_manager.py | 2 +- 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tox.ini b/tox.ini index 99402f4322..6636dba140 100644 --- a/tox.ini +++ b/tox.ini @@ -33,6 +33,6 @@ commands = {posargs} [flake8] show-source = True -ignore = E125,F401,F403,F811,F821,F841,H +ignore = E125,F401,F403,F811,F821,F841,H102,H103,H201,H23,H301,H306,H401,H402,H403,H404,H702,H703 builtins = _ exclude=.venv,.tox,dist,doc,openstack,*egg,rsdns,tools diff --git a/trove/extensions/mysql/service.py b/trove/extensions/mysql/service.py index b7f206484d..b77c2aff08 100644 --- a/trove/extensions/mysql/service.py +++ b/trove/extensions/mysql/service.py @@ -222,7 +222,7 @@ class UserAccessController(wsgi.Controller): username, hostname = unquote_user_host(user_id) access = models.User.access(context, instance_id, username, hostname) databases = [db.name for db in access.databases] - if not id in databases: + if id not in databases: raise exception.DatabaseNotFound(uuid=id) models.User.revoke(context, instance_id, username, hostname, id) return wsgi.Result(None, 202) diff --git a/trove/extensions/security_group/service.py b/trove/extensions/security_group/service.py index 515cc1788c..4a16deeba1 100644 --- a/trove/extensions/security_group/service.py +++ b/trove/extensions/security_group/service.py @@ -105,7 +105,7 @@ class SecurityGroupRuleController(wsgi.Controller): def _validate_create_body(self, body): try: - # TODO: Add some better validation here around ports, + # TODO(slicknik): Add some better validation here around ports, # protocol, and cidr values. body['security_group_rule'] body['security_group_rule']['group_id'] diff --git a/trove/guestagent/db/models.py b/trove/guestagent/db/models.py index f723cbe02f..f010583b1e 100644 --- a/trove/guestagent/db/models.py +++ b/trove/guestagent/db/models.py @@ -303,12 +303,12 @@ class MySQLDatabase(Base): if not value: pass elif self._character_set: - if not value in self.charset[self._character_set]: + if value not in self.charset[self._character_set]: msg = "'%s' not a valid collation for charset '%s'" raise ValueError(msg % (value, self._character_set)) self._collate = value else: - if not value in self.collation: + if value not in self.collation: raise ValueError("'%s' not a valid collation" % value) self._collate = value self._character_set = self.collation[value] diff --git a/trove/tests/api/instances.py b/trove/tests/api/instances.py index 3f195a2d36..dfbab06774 100644 --- a/trove/tests/api/instances.py +++ b/trove/tests/api/instances.py @@ -1025,8 +1025,8 @@ class DeleteInstance(object): except backend_exception.VolumeNotFound: pass - #TODO: make sure that the actual instance, volume, guest status, and DNS - # entries are deleted. + #TODO(tim-simpson): make sure that the actual instance, volume, + # guest status, and DNS entries are deleted. @test(depends_on=[WaitForGuestInstallationToFinish], diff --git a/trove/tests/api/instances_actions.py b/trove/tests/api/instances_actions.py index 6e19ec2eb1..ab82df261c 100644 --- a/trove/tests/api/instances_actions.py +++ b/trove/tests/api/instances_actions.py @@ -635,7 +635,7 @@ class ResizeInstanceVolume(object): for database in databases: db_list.append(database.name) for name in self.expected_dbs: - if not name in db_list: + if name not in db_list: fail("Database %s was not found after the volume resize. " "Returned list: %s" % (name, databases)) diff --git a/trove/tests/api/mgmt/instances.py b/trove/tests/api/mgmt/instances.py index fcc24eeafb..8fdf8d9d9c 100644 --- a/trove/tests/api/mgmt/instances.py +++ b/trove/tests/api/mgmt/instances.py @@ -106,7 +106,8 @@ def mgmt_instance_get(): instance.has_field('volume', dict, volume_check) else: instance.has_field('volume', None) - #TODO: Validate additional fields, assert no extra fields exist. + #TODO(tim-simpson): Validate additional fields, assert + # no extra fields exist. with CollectionCheck("server", api_instance.server) as server: server.has_element("addresses", dict) server.has_element("deleted", bool) @@ -183,7 +184,8 @@ class WhenMgmtInstanceGetIsCalledButServerIsNotReady(object): # Can be None if no volume is given on this instance. instance.has_field('server', None) instance.has_field('volume', None) - #TODO: Validate additional fields, assert no extra fields exist. + #TODO(tim-simpson): Validate additional fields, + # assert no extra fields exist. @test(depends_on_classes=[CreateInstance], groups=[GROUP]) diff --git a/trove/tests/unittests/guestagent/test_api.py b/trove/tests/unittests/guestagent/test_api.py index 387f1dbd79..07f49e0523 100644 --- a/trove/tests/unittests/guestagent/test_api.py +++ b/trove/tests/unittests/guestagent/test_api.py @@ -57,7 +57,7 @@ class ApiTest(testtools.TestCase): self.assertTrue(self.api._check_for_hearbeat()) def test_check_for_heartbeat_exception(self): - # TODO (juice) maybe it would be ok to extend the test to validate + # TODO(juice): maybe it would be ok to extend the test to validate # the is_active method on the heartbeat when(db_models.DatabaseModelBase).find_by(instance_id=any()).thenRaise( exception.ModelNotFoundError) @@ -68,7 +68,7 @@ class ApiTest(testtools.TestCase): verify(agent_models.AgentHeartBeat, times=0).is_active(any()) def test_check_for_heartbeat_negative(self): - # TODO (juice) maybe it would be ok to extend the test to validate + # TODO(juice): maybe it would be ok to extend the test to validate # the is_active method on the heartbeat when(db_models.DatabaseModelBase).find_by( instance_id=any()).thenReturn('agent') diff --git a/trove/tests/unittests/guestagent/test_manager.py b/trove/tests/unittests/guestagent/test_manager.py index c5b38f7434..2eee8b73ad 100644 --- a/trove/tests/unittests/guestagent/test_manager.py +++ b/trove/tests/unittests/guestagent/test_manager.py @@ -144,7 +144,7 @@ class GuestAgentManagerTest(testtools.TestCase): SEC_COUNT = 1 if is_mysql_installed else 0 migrate_count = 1 * COUNT if not backup_id else 0 - # TODO (juice) this should stub an instance of the MySqlAppStatus + # TODO(juice): this should stub an instance of the MySqlAppStatus mock_status = mock() when(dbaas.MySqlAppStatus).get().thenReturn(mock_status) when(mock_status).begin_mysql_install().thenReturn(None)