From fa95c8bdc2e17b54ef6ff69e2e23b1faeb6a112a Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 13 Aug 2013 23:50:17 -0300 Subject: 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 --- keystone/clean.py | 13 +++++++++---- keystone/cli.py | 4 ++-- keystone/tests/test_s3_token_middleware.py | 4 ++-- keystone/tests/test_sql_upgrade.py | 4 ++-- tox.ini | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/keystone/clean.py b/keystone/clean.py index 7684210a..cb6c69c0 100644 --- a/keystone/clean.py +++ b/keystone/clean.py @@ -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) diff --git a/keystone/cli.py b/keystone/cli.py index 18c095ce..6575f2e9 100644 --- a/keystone/cli.py +++ b/keystone/cli.py @@ -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()) diff --git a/keystone/tests/test_s3_token_middleware.py b/keystone/tests/test_s3_token_middleware.py index ec31f2ac..2d561c10 100644 --- a/keystone/tests/test_s3_token_middleware.py +++ b/keystone/tests/test_s3_token_middleware.py @@ -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') diff --git a/keystone/tests/test_sql_upgrade.py b/keystone/tests/test_sql_upgrade.py index 7d60ced4..0ee63433 100644 --- a/keystone/tests/test_sql_upgrade.py +++ b/keystone/tests/test_sql_upgrade.py @@ -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") diff --git a/tox.ini b/tox.ini index 1fe184ea..125b7845 100644 --- a/tox.ini +++ b/tox.ini @@ -34,7 +34,7 @@ commands = {posargs} [flake8] show-source = true -# H304: no relative imports. +# H304 no relative imports. ignore = H304 builtins = _ -- cgit