launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26135
[Merge] ~cjwatson/launchpad:py3-map into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-map into launchpad:master.
Commit message:
Don't assume map returns a list
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/397105
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-map into launchpad:master.
diff --git a/lib/lp/archivepublisher/htaccess.py b/lib/lp/archivepublisher/htaccess.py
index caba12f..1d29fb8 100644
--- a/lib/lp/archivepublisher/htaccess.py
+++ b/lib/lp/archivepublisher/htaccess.py
@@ -15,7 +15,6 @@ __all__ = [
import base64
import crypt
-from operator import itemgetter
import os
from lp.registry.model.person import Person
@@ -98,10 +97,10 @@ def htpasswd_credentials_for_archive(archive):
tokens = list(tokens)
# Preload map with person ID to person name.
- person_ids = map(itemgetter(0), tokens)
+ person_ids = {token[0] for token in tokens}
names = dict(
IStore(Person).find(
- (Person.id, Person.name), Person.id.is_in(set(person_ids))))
+ (Person.id, Person.name), Person.id.is_in(person_ids)))
# Format the user field by combining the token list with the person list
# (when token has person_id) or prepending a '+' (for named tokens).
diff --git a/lib/lp/bugs/mail/tests/test_handler.py b/lib/lp/bugs/mail/tests/test_handler.py
index 90a9e4e..1f6df0b 100644
--- a/lib/lp/bugs/mail/tests/test_handler.py
+++ b/lib/lp/bugs/mail/tests/test_handler.py
@@ -108,7 +108,7 @@ class TestMaloneHandler(TestCaseWithFactory):
handler.extractAndAuthenticateCommands(message,
'new@xxxxxxxxxxxxxxxxxx')
self.assertEqual(mail_handled, None)
- self.assertEqual(map(str, commands), [
+ self.assertEqual([str(command) for command in commands], [
'bug new',
'affects malone',
])
diff --git a/lib/lp/registry/browser/tests/test_distroseries.py b/lib/lp/registry/browser/tests/test_distroseries.py
index 0542991..063158d 100644
--- a/lib/lp/registry/browser/tests/test_distroseries.py
+++ b/lib/lp/registry/browser/tests/test_distroseries.py
@@ -1501,7 +1501,9 @@ class TestDistroSeriesLocalDifferences(TestCaseWithFactory,
"requested. Please give Launchpad some time to "
"complete these.").format(dsd.derived_series),
}
- observed = map(vars, view.request.response.notifications)
+ observed = [
+ vars(notification)
+ for notification in view.request.response.notifications]
self.assertEqual([expected], observed)
def test_requestUpgrades_is_efficient(self):
diff --git a/lib/lp/scripts/garbo.py b/lib/lp/scripts/garbo.py
index 637f7b4..12fd7b4 100644
--- a/lib/lp/scripts/garbo.py
+++ b/lib/lp/scripts/garbo.py
@@ -505,7 +505,7 @@ class PopulateDistributionSourcePackageCache(TunableLoop):
DistributionSourcePackageCache.archiveID,
DistributionSourcePackageCache.distributionID,
DistributionSourcePackageCache.sourcepackagenameID),
- map(Row, cache_filter_data)))
+ [Row(cache_key) for cache_key in cache_filter_data]))
for dspc in rows:
existing_records.add(
(dspc.archiveID, dspc.distributionID,
@@ -626,7 +626,7 @@ class PopulateLatestPersonSourcePackageReleaseCache(TunableLoop):
lpsprc.upload_archive_id,
lpsprc.upload_distroseries_id,
lpsprc.sourcepackagename_id),
- map(Row, cache_filter_data)))
+ [Row(cache_key) for cache_key in cache_filter_data]))
for lpsprc_record in rs:
key = (
lpsprc_record.maintainer_id,
diff --git a/lib/lp/services/webapp/tests/test_batching.py b/lib/lp/services/webapp/tests/test_batching.py
index b543042..9415a8e 100644
--- a/lib/lp/services/webapp/tests/test_batching.py
+++ b/lib/lp/services/webapp/tests/test_batching.py
@@ -446,7 +446,7 @@ class TestStormRangeFactory(TestCaseWithFactory):
1, datetime(2011, 7, 25, 0, 0, 0, tzinfo=pytz.UTC), 'foo', 'bar']
limits = range_factory.limitsGroupedByOrderDirection(order_by, limits)
equals_expressions = range_factory.equalsExpressionsFromLimits(limits)
- equals_expressions = map(compile, equals_expressions)
+ equals_expressions = [compile(expr) for expr in equals_expressions]
self.assertEqual(
['Person.id = ?', 'Person.datecreated = ?', 'Person.name = ?',
'Person.displayname = ?'],
diff --git a/lib/lp/soyuz/browser/archivesubscription.py b/lib/lp/soyuz/browser/archivesubscription.py
index db8fa40..47ab800 100644
--- a/lib/lp/soyuz/browser/archivesubscription.py
+++ b/lib/lp/soyuz/browser/archivesubscription.py
@@ -164,7 +164,7 @@ class ArchiveSubscribersView(LaunchpadFormView):
Bulk loads the related Person records.
"""
batch = list(self.batchnav.currentBatch())
- ids = map(attrgetter('subscriber_id'), batch)
+ ids = [subscription.subscriber_id for subscription in batch]
list(getUtility(IPersonSet).getPrecachedPersonsFromIDs(ids,
need_validity=True))
return batch
diff --git a/lib/lp/soyuz/browser/queue.py b/lib/lp/soyuz/browser/queue.py
index 520fd68..d4de780 100644
--- a/lib/lp/soyuz/browser/queue.py
+++ b/lib/lp/soyuz/browser/queue.py
@@ -10,7 +10,6 @@ __all__ = [
'QueueItemsView',
]
-from collections import defaultdict
from operator import attrgetter
from lazr.delegates import delegate_to
@@ -67,10 +66,6 @@ from lp.soyuz.model.files import (
SourcePackageReleaseFile,
)
from lp.soyuz.model.packagecopyjob import PackageCopyJob
-from lp.soyuz.model.queue import (
- PackageUploadBuild,
- PackageUploadSource,
- )
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
@@ -204,9 +199,9 @@ class QueueItemsView(LaunchpadView):
archives = load_related(
Archive, package_copy_jobs, ['source_archive_id'])
load_related(Distribution, archives, ['distributionID'])
- person_ids = map(attrgetter('ownerID'), archives)
+ person_ids = [archive.ownerID for archive in archives]
jobs = load_related(Job, package_copy_jobs, ['job_id'])
- person_ids.extend(map(attrgetter('requester_id'), jobs))
+ person_ids.extend(job.requester_id for job in jobs)
list(getUtility(IPersonSet).getPrecachedPersonsFromIDs(
person_ids, need_validity=True))
diff --git a/lib/lp/soyuz/model/archivesubscriber.py b/lib/lp/soyuz/model/archivesubscriber.py
index 72386ef..cb3d3e5 100644
--- a/lib/lp/soyuz/model/archivesubscriber.py
+++ b/lib/lp/soyuz/model/archivesubscriber.py
@@ -220,7 +220,7 @@ class ArchiveSubscriberSet:
result = self._getBySubscriber(subscriber, archive, True, True)
def eager_load(rows):
- subscriptions = map(itemgetter(0), rows)
+ subscriptions = [row[0] for row in rows]
precache_permission_for_objects(
None, 'launchpad.View', subscriptions)
archives = load_related(Archive, subscriptions, ['archive_id'])