← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/turnip:simplify-inlineCallbacks-return into turnip:master

 

Colin Watson has proposed merging ~cjwatson/turnip:simplify-inlineCallbacks-return into turnip:master.

Commit message:
Stop using defer.returnValue

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/turnip/+git/turnip/+merge/407203

On Python 3, we can just return values directly.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/turnip:simplify-inlineCallbacks-return into turnip:master.
diff --git a/turnip/pack/hookrpc.py b/turnip/pack/hookrpc.py
index cf1e329..6ec1a06 100644
--- a/turnip/pack/hookrpc.py
+++ b/turnip/pack/hookrpc.py
@@ -222,9 +222,9 @@ class HookRPCHandler(object):
                 auth_params=auth_params, ref_path=ref_path)
         # cached_permissions is a shallow copy of the key index for
         # self.ref_permissions, so changes will be updated in that.
-        defer.returnValue(
-            {base64.b64encode(ref).decode('UTF-8'): cached_permissions[ref]
-             for ref in paths})
+        return {
+            base64.b64encode(ref).decode('UTF-8'): cached_permissions[ref]
+            for ref in paths}
 
     @defer.inlineCallbacks
     def notify(self, path, loose_object_count, pack_count, auth_params):
@@ -300,7 +300,7 @@ class HookRPCHandler(object):
             raise
         log_context.log.info("getMergeProposalURL done: ref_path={path}",
                              path=path)
-        defer.returnValue(mp_url)
+        return mp_url
 
 
 class HookRPCServerFactory(RPCServerFactory):
diff --git a/turnip/pack/http.py b/turnip/pack/http.py
index 0d11d91..1039b1e 100644
--- a/turnip/pack/http.py
+++ b/turnip/pack/http.py
@@ -287,8 +287,8 @@ class BaseSmartHTTPResource(resource.Resource):
         if request.getUser() or request.getPassword():
             params = yield self.root.authenticateWithPassword(
                 request.getUser(), request.getPassword())
-            defer.returnValue(params)
-        defer.returnValue({})
+            return params
+        return {}
 
     @defer.inlineCallbacks
     def connectToBackend(self, factory, service, path, content, request):
@@ -853,7 +853,7 @@ class SmartHTTPFrontendResource(resource.Resource):
         except xmlrpc.Fault as e:
             code = translate_xmlrpc_fault(e.faultCode)
             if code == TurnipFaultCode.UNAUTHORIZED:
-                defer.returnValue({})
+                return {}
             else:
                 raise
-        defer.returnValue(translated)
+        return translated
diff --git a/turnip/pack/ssh.py b/turnip/pack/ssh.py
index 0f27390..39979ba 100644
--- a/turnip/pack/ssh.py
+++ b/turnip/pack/ssh.py
@@ -228,7 +228,7 @@ class SmartSSHRealm:
         user_dict = yield mind.lookupUserDetails(
             self.authentication_proxy, avatar_id)
         avatar = SmartSSHAvatar(user_dict, self.service)
-        defer.returnValue((interfaces[0], avatar, avatar.logout))
+        return interfaces[0], avatar, avatar.logout
 
 
 class SmartSSHService(SSHService):
diff --git a/turnip/pack/tests/test_functional.py b/turnip/pack/tests/test_functional.py
index 1ef2125..163bf0b 100644
--- a/turnip/pack/tests/test_functional.py
+++ b/turnip/pack/tests/test_functional.py
@@ -158,7 +158,7 @@ class FunctionalTestMixin(WithScenarios):
             self.addDetail('stdout', text_content(six.ensure_text(out)))
             self.addDetail('stderr', text_content(six.ensure_text(err)))
             self.assertEqual(0, code)
-        defer.returnValue(out)
+        return out
 
     @defer.inlineCallbacks
     def assertCommandFailure(self, command, path='.'):
@@ -173,7 +173,7 @@ class FunctionalTestMixin(WithScenarios):
             self.addDetail('stdout', text_content(six.ensure_text(out)))
             self.addDetail('stderr', text_content(six.ensure_text(err)))
             self.assertNotEqual(0, code)
-        defer.returnValue((out, err))
+        return out, err
 
     def assertStatsdSuccess(self, repo, command):
         metrics = ['clock_time', 'user_time', 'system_time', 'max_rss']
@@ -822,7 +822,7 @@ class TestSmartHTTPFrontendFunctional(FrontendFunctionalTestMixin, TestCase):
     def get_symbolic_ref(self, path, name):
         out = yield self.getProcessOutput(
             b'git', (b'symbolic-ref', name), env=os.environ, path=path)
-        defer.returnValue(out.rstrip(b'\n'))
+        return out.rstrip(b'\n')
 
     @defer.inlineCallbacks
     def test_turnip_set_symbolic_ref(self):
diff --git a/turnip/pack/tests/test_hooks.py b/turnip/pack/tests/test_hooks.py
index eb2a37c..db37120 100644
--- a/turnip/pack/tests/test_hooks.py
+++ b/turnip/pack/tests/test_hooks.py
@@ -211,7 +211,7 @@ class HookTestMixin(object):
             code, stdout, stderr = yield d
         finally:
             self.hookrpc_handler.unregisterKey(key)
-        defer.returnValue((code, stdout, stderr))
+        return code, stdout, stderr
 
     @defer.inlineCallbacks
     def assertAccepted(self, updates, permissions):
diff --git a/turnip/pack/tests/test_http.py b/turnip/pack/tests/test_http.py
index ef8f835..229546b 100644
--- a/turnip/pack/tests/test_http.py
+++ b/turnip/pack/tests/test_http.py
@@ -158,7 +158,7 @@ class ErrorTestMixin(object):
         else:
             self.assertIs(None, self.root.backend_transport)
         yield rendered
-        defer.returnValue(self.request)
+        return self.request
 
     @defer.inlineCallbacks
     def test_backend_immediately_dies(self):