← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:yield-from into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:yield-from into launchpad:master.

Commit message:
Use "yield from" where appropriate

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

`pyupgrade --py3-plus` skipped these transformations for various reasons, but they all seem safe.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:yield-from into launchpad:master.
diff --git a/lib/lp/archiveuploader/dscfile.py b/lib/lp/archiveuploader/dscfile.py
index d16de4c..5ea8210 100644
--- a/lib/lp/archiveuploader/dscfile.py
+++ b/lib/lp/archiveuploader/dscfile.py
@@ -638,15 +638,14 @@ class DSCFile(SourceUploadFile, SignableTagFile):
                 "No file checker for source format %s." % self.format
             )
 
-        for error in file_checker(
+        yield from file_checker(
             self.filename,
             file_type_counts,
             component_orig_tar_counts,
             component_orig_tar_signature_counts,
             bzip2_count,
             xz_count,
-        ):
-            yield error
+        )
 
         if files_missing:
             yield UploadError(
@@ -654,9 +653,8 @@ class DSCFile(SourceUploadFile, SignableTagFile):
                 "skipping package unpack verification."
             )
         else:
-            for error in self.unpackAndCheckSource():
-                # Pass on errors found when unpacking the source.
-                yield error
+            # Pass on errors found when unpacking the source.
+            yield from self.unpackAndCheckSource()
 
     def unpackAndCheckSource(self):
         """Verify uploaded source using dpkg-source."""
diff --git a/lib/lp/services/database/decoratedresultset.py b/lib/lp/services/database/decoratedresultset.py
index 89ad74d..e4d8c7f 100644
--- a/lib/lp/services/database/decoratedresultset.py
+++ b/lib/lp/services/database/decoratedresultset.py
@@ -176,8 +176,7 @@ class DecoratedResultSet:
                 results = self.bulk_decorator(pre_iter_rows, result_slice)
             else:
                 results = self.bulk_decorator(pre_iter_rows)
-            for value in results:
-                yield value
+            yield from results
         else:
             if self.pre_iter_hook is not None:
                 pre_iter_rows = self._extract_plain_and_result(results)[1]
diff --git a/lib/lp/testing/utilities/retest.py b/lib/lp/testing/utilities/retest.py
index df889a8..7c53ca8 100755
--- a/lib/lp/testing/utilities/retest.py
+++ b/lib/lp/testing/utilities/retest.py
@@ -73,8 +73,7 @@ def gen_test_lines(lines):
     lines = iter(lines)
     for line in lines:
         if p_start(line):
-            for line in takewhile(p_take, lines):
-                yield line
+            yield from takewhile(p_take, lines)
 
 
 def gen_tests(test_lines):