Clean hacking errors in advance of hacking update

The next patch syncs with global requirements, including an
update to hacking. These fixes align the codebase with those
new rules.

Change-Id: I16e5a4ffa877fb46d2fb28d881642185c801b628
This commit is contained in:
Monty Taylor 2013-08-13 23:50:17 -03:00 committed by Morgan Fainberg
parent 7851a3cd62
commit fa95c8bdc2
5 changed files with 16 additions and 11 deletions

View File

@ -23,18 +23,23 @@ def check_length(property_name, value, min_length=1, max_length=64):
msg = _("%s cannot be empty.") % property_name
else:
msg = (_("%(property_name)s cannot be less than "
"%(min_length)s characters.")) % locals()
"%(min_length)s characters.") % dict(
property_name=property_name, min_length=min_length))
raise exception.ValidationError(msg)
if len(value) > max_length:
msg = (_("%(property_name)s should not be greater than "
"%(max_length)s characters.")) % locals()
"%(max_length)s characters.") % dict(
property_name=property_name, max_length=max_length))
raise exception.ValidationError(msg)
def check_type(property_name, value, expected_type, display_expected_type):
if not isinstance(value, expected_type):
msg = _("%(property_name)s is not a "
"%(display_expected_type)s") % locals()
msg = (_("%(property_name)s is not a "
"%(display_expected_type)s") % dict(
property_name=property_name,
display_expected_type=display_expected_type))
raise exception.ValidationError(msg)

View File

@ -79,7 +79,7 @@ class DbSync(BaseApp):
package = importutils.import_module(package_name)
repo_path = os.path.abspath(os.path.dirname(package.__file__))
except ImportError:
print _("This extension does not provide migrations.")
print(_("This extension does not provide migrations."))
exit(0)
try:
# Register the repo with the version control API
@ -115,7 +115,7 @@ class DbVersion(BaseApp):
repo_path = os.path.abspath(os.path.dirname(package.__file__))
print(migration.db_version(repo_path))
except ImportError:
print _("This extension does not provide migrations.")
print(_("This extension does not provide migrations."))
exit(1)
else:
print(migration.db_version())

View File

@ -225,9 +225,9 @@ class S3TokenMiddlewareTestUtil(unittest.TestCase):
def test_split_path_invalid_path(self):
try:
s3_token.split_path('o\nn e', 2)
except ValueError, err:
except ValueError as err:
self.assertEquals(str(err), 'Invalid path: o%0An%20e')
try:
s3_token.split_path('o\nn e', 2, 3, True)
except ValueError, err:
except ValueError as err:
self.assertEquals(str(err), 'Invalid path: o%0An%20e')

View File

@ -1398,7 +1398,7 @@ class SqlUpgradeTests(SqlMigrateBase):
total = connection.execute("SELECT count(*) "
"from information_schema.TABLES "
"where TABLE_SCHEMA='%(database)s'" %
locals())
dict(database=database))
self.assertTrue(total.scalar() > 0, "No tables found. Wrong schema?")
noninnodb = connection.execute("SELECT table_name "
@ -1406,7 +1406,7 @@ class SqlUpgradeTests(SqlMigrateBase):
"where TABLE_SCHEMA='%(database)s' "
"and ENGINE!='InnoDB' "
"and TABLE_NAME!='migrate_version'" %
locals())
dict(database=database))
names = [x[0] for x in noninnodb]
self.assertEqual(names, [],
"Non-InnoDB tables exist")

View File

@ -34,7 +34,7 @@ commands = {posargs}
[flake8]
show-source = true
# H304: no relative imports.
# H304 no relative imports.
ignore = H304
builtins = _