From: Steve Baker Date: Thu, 8 Aug 2013 02:03:03 +0000 (+1200) Subject: Fix H501 Do not use locals() for string formatting X-Git-Tag: 2014.1~261^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6e70181f742cd4605b379ad02f8ddfdaeaf45316;p=openstack-build%2Fheat-build.git Fix H501 Do not use locals() for string formatting This is triggered in the pep8 check when using the syncronised requirements versions. Change-Id: If0e38fecaf32d4ba6ec9755f2f11c675acf6d20b --- diff --git a/heat/common/config.py b/heat/common/config.py index ab07ed29..7c15817e 100644 --- a/heat/common/config.py +++ b/heat/common/config.py @@ -179,4 +179,6 @@ def load_paste_app(app_name=None): except (LookupError, ImportError) as e: raise RuntimeError("Unable to load %(app_name)s from " "configuration file %(conf_file)s." - "\nGot: %(e)r" % locals()) + "\nGot: %(e)r" % {'app_name': app_name, + 'conf_file': conf_file, + 'e': e}) diff --git a/heat/common/wsgi.py b/heat/common/wsgi.py index 6d047451..b2e142e5 100644 --- a/heat/common/wsgi.py +++ b/heat/common/wsgi.py @@ -315,13 +315,13 @@ class Debug(Middleware): @webob.dec.wsgify def __call__(self, req): - print ("*" * 40) + " REQUEST ENVIRON" + print(("*" * 40) + " REQUEST ENVIRON") for key, value in req.environ.items(): print(key, "=", value) print resp = req.get_response(self.application) - print ("*" * 40) + " RESPONSE HEADERS" + print(("*" * 40) + " RESPONSE HEADERS") for (key, value) in resp.headers.iteritems(): print(key, "=", value) print @@ -336,7 +336,7 @@ class Debug(Middleware): Iterator that prints the contents of a wrapper string iterator when iterated. """ - print ("*" * 40) + " BODY" + print(("*" * 40) + " BODY") for part in app_iter: sys.stdout.write(part) sys.stdout.flush() diff --git a/heat/tests/test_api_openstack_v1.py b/heat/tests/test_api_openstack_v1.py index 80d37a68..65cbecde 100644 --- a/heat/tests/test_api_openstack_v1.py +++ b/heat/tests/test_api_openstack_v1.py @@ -684,7 +684,8 @@ class StackControllerTest(ControllerTest, HeatTestCase): def test_lookup_nonexistant(self): stack_name = 'wibble' - req = self._get('/stacks/%(stack_name)s' % locals()) + req = self._get('/stacks/%(stack_name)s' % { + 'stack_name': stack_name}) error = heat_exc.StackNotFound(stack_name='a') self.m.StubOutWithMock(rpc, 'call') @@ -734,7 +735,8 @@ class StackControllerTest(ControllerTest, HeatTestCase): def test_lookup_resource_nonexistant(self): stack_name = 'wibble' - req = self._get('/stacks/%(stack_name)s/resources' % locals()) + req = self._get('/stacks/%(stack_name)s/resources' % { + 'stack_name': stack_name}) error = heat_exc.StackNotFound(stack_name='a') self.m.StubOutWithMock(rpc, 'call')