← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:pyupgrade-py3-archivepublisher into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:pyupgrade-py3-archivepublisher into launchpad:master.

Commit message:
lp.archivepublisher: Apply "pyupgrade --py3-plus"

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/412468
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:pyupgrade-py3-archivepublisher into launchpad:master.
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index 6115e5c..7121771 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -4,3 +4,5 @@
 5d46ca0970916c2b161761aee29f46419dd3efea
 # apply pyupgrade --py3-plus to lp.app
 7fbeaae55d7d282ccda47c76a27c879e04ee14e9
+# apply pyupgrade --py3-plus to lp.archivepublisher
+c348b945c29c723201380d9aca0e0c0298037c8c
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 162ad2f..ea4c505 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -38,7 +38,7 @@ repos:
         alias: pyupgrade-py3
         name: pyupgrade (--py3-plus)
         args: [--keep-percent-format, --py3-plus]
-        files: ^lib/lp/(answers|app)/
+        files: ^lib/lp/(answers|app|archivepublisher)/
 -   repo: https://github.com/PyCQA/isort
     rev: 5.9.2
     hooks:
diff --git a/lib/lp/archivepublisher/config.py b/lib/lp/archivepublisher/config.py
index bfc4427..de45925 100644
--- a/lib/lp/archivepublisher/config.py
+++ b/lib/lp/archivepublisher/config.py
@@ -125,7 +125,7 @@ def getPubConfig(archive):
     return pubconf
 
 
-class Config(object):
+class Config:
     """Manage a publisher configuration from the database. (Read Only)
     This class provides a useful abstraction so that if we change
     how the database stores configuration then the publisher will not
diff --git a/lib/lp/archivepublisher/domination.py b/lib/lp/archivepublisher/domination.py
index 3ba380d..22c8a59 100644
--- a/lib/lp/archivepublisher/domination.py
+++ b/lib/lp/archivepublisher/domination.py
@@ -59,7 +59,6 @@ from operator import (
     )
 
 import apt_pkg
-import six
 from six.moves import (
     filter as ifilter,
     filterfalse as ifilterfalse,
@@ -668,7 +667,7 @@ class Dominator:
             bins = self.findBinariesForDomination(distroarchseries, pocket)
             sorted_packages = self._sortPackages(bins, generalization)
             self.logger.info("Planning domination of binaries...")
-            for name, pubs in six.iteritems(sorted_packages):
+            for name, pubs in sorted_packages.items():
                 self.logger.debug("Planning domination of %s" % name)
                 assert len(pubs) > 0, "Dominating zero binaries!"
                 live_versions = find_live_binary_versions_pass_1(pubs)
@@ -773,7 +772,7 @@ class Dominator:
         delete = []
 
         self.logger.debug("Dominating sources...")
-        for name, pubs in six.iteritems(sorted_packages):
+        for name, pubs in sorted_packages.items():
             self.logger.debug("Dominating %s" % name)
             assert len(pubs) > 0, "Dominating zero sources!"
             live_versions = find_live_source_versions(pubs)
diff --git a/lib/lp/archivepublisher/model/ftparchive.py b/lib/lp/archivepublisher/model/ftparchive.py
index da2ecf6..f5bfe02 100644
--- a/lib/lp/archivepublisher/model/ftparchive.py
+++ b/lib/lp/archivepublisher/model/ftparchive.py
@@ -200,7 +200,7 @@ class FTPArchiveHandler:
         stderr_handler.finalize()
         failures = sorted(
             (tag, receiver.returncode)
-            for tag, receiver in six.iteritems(returncodes)
+            for tag, receiver in returncodes.items()
                 if receiver.returncode != 0)
         if len(failures) > 0:
             by_arch = ["%s (returned %d)" % failure for failure in failures]
@@ -531,7 +531,7 @@ class FTPArchiveHandler:
 
         if os.path.exists(extra_extra_overrides):
             # XXX kiko 2006-08-24: This is untested.
-            eef = open(extra_extra_overrides, "r")
+            eef = open(extra_extra_overrides)
             extras = {}
             for line in eef:
                 line = line.strip()
@@ -627,7 +627,7 @@ class FTPArchiveHandler:
             SourcePackageName.name,
             LibraryFileAlias.filename,
             Component.name,
-            Concatenate(u"binary-", DistroArchSeries.architecturetag),
+            Concatenate("binary-", DistroArchSeries.architecturetag),
             )
         join_conditions = [
             BinaryPackageRelease.id ==
@@ -712,8 +712,8 @@ class FTPArchiveHandler:
             updateFileList(*file_details)
 
         self.log.debug("Writing file lists for %s" % suite)
-        for component, architectures in six.iteritems(filelist):
-            for architecture, file_names in six.iteritems(architectures):
+        for component, architectures in filelist.items():
+            for architecture, file_names in architectures.items():
                 # XXX wgrant 2010-10-06: There must be a better place to do
                 # this.
                 if architecture == "source":
diff --git a/lib/lp/archivepublisher/publishing.py b/lib/lp/archivepublisher/publishing.py
index a1f4ec0..f18ca9f 100644
--- a/lib/lp/archivepublisher/publishing.py
+++ b/lib/lp/archivepublisher/publishing.py
@@ -34,7 +34,6 @@ from debian.deb822 import (
     _multivalued,
     Release,
     )
-import six
 from storm.expr import Desc
 from zope.component import getUtility
 from zope.interface import (
@@ -403,7 +402,7 @@ class ByHashes:
             child.prune()
 
 
-class Publisher(object):
+class Publisher:
     """Publisher is the class used to provide the facility to publish
     files in the pool of a Distribution. The publisher objects will be
     instantiated by the archive build scripts and will be used throughout
@@ -748,9 +747,9 @@ class Publisher(object):
 
         archive_file_suites = set()
         for container in getUtility(IArchiveFileSet).getContainersToReap(
-                self.archive, container_prefix=u"release:"):
+                self.archive, container_prefix="release:"):
             distroseries, pocket = self.distro.getDistroSeriesAndPocket(
-                container[len(u"release:"):])
+                container[len("release:"):])
             archive_file_suites.add(distroseries.getSuite(pocket))
 
         for distroseries in self.distro:
@@ -829,7 +828,7 @@ class Publisher(object):
                     with open_func(index) as index_file:
                         if index_file.read(1):
                             return distroseries
-                except IOError:
+                except OSError:
                     pass
 
     def createSeriesAliases(self):
@@ -966,7 +965,7 @@ class Publisher(object):
                             translation_stanza.makeOutput().encode('utf-8')
                             + b'\n\n')
 
-            for index in six.itervalues(indices):
+            for index in indices.values():
                 index.close()
 
         if separate_long_descriptions:
diff --git a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py
index 03bfe43..b2a1060 100644
--- a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py
+++ b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py
@@ -13,7 +13,6 @@ import os
 import shutil
 
 from pytz import utc
-import six
 from zope.component import getUtility
 
 from lp.archivepublisher.config import getPubConfig
@@ -284,7 +283,7 @@ class PublishFTPMaster(LaunchpadCronScript):
         :param archive_purpose: The (purpose of the) archive to copy.
         """
         for purpose, archive_config in (
-                six.iteritems(self.configs[distribution])):
+                self.configs[distribution].items()):
             dists = get_dists(archive_config)
             backup_dists = get_backup_dists(archive_config)
             execute_subprocess(
@@ -314,15 +313,14 @@ class PublishFTPMaster(LaunchpadCronScript):
         run died while in this state, restore the directory to its
         permanent location.
         """
-        for distro_configs in six.itervalues(self.configs):
-            for archive_config in six.itervalues(distro_configs):
+        for distro_configs in self.configs.values():
+            for archive_config in distro_configs.values():
                 self.recoverArchiveWorkingDir(archive_config)
 
     def setUpDirs(self):
         """Create archive roots and such if they did not yet exist."""
-        for distro_configs in six.itervalues(self.configs):
-            for archive_purpose, archive_config in (
-                    six.iteritems(distro_configs)):
+        for distro_configs in self.configs.values():
+            for archive_purpose, archive_config in distro_configs.items():
                 archiveroot = archive_config.archiveroot
                 if not file_exists(archiveroot):
                     self.logger.debug(
@@ -403,7 +401,7 @@ class PublishFTPMaster(LaunchpadCronScript):
         backup dists directory around.
         """
         self.logger.debug("Moving the new dists into place...")
-        for archive_config in six.itervalues(self.configs[distribution]):
+        for archive_config in self.configs[distribution].values():
             # Use the dists "working location" as a temporary place to
             # move the current dists out of the way for the switch.  If
             # we die in this state, the next run will know to move the
@@ -418,7 +416,7 @@ class PublishFTPMaster(LaunchpadCronScript):
 
     def clearEmptyDirs(self, distribution):
         """Clear out any redundant empty directories."""
-        for archive_config in six.itervalues(self.configs[distribution]):
+        for archive_config in self.configs[distribution].values():
             execute_subprocess(
                 ["find", archive_config.archiveroot, "-type", "d", "-empty",
                  "-delete"],
@@ -428,7 +426,7 @@ class PublishFTPMaster(LaunchpadCronScript):
         """Run the finalize.d parts to finalize publication."""
         archive_roots = ' '.join([
             archive_config.archiveroot
-            for archive_config in six.itervalues(self.configs[distribution])])
+            for archive_config in self.configs[distribution].values()])
 
         env = {
             'SECURITY_UPLOAD_ONLY': 'yes' if security_only else 'no',
diff --git a/lib/lp/archivepublisher/scripts/sync_signingkeys.py b/lib/lp/archivepublisher/scripts/sync_signingkeys.py
index 816081a..a856f55 100644
--- a/lib/lp/archivepublisher/scripts/sync_signingkeys.py
+++ b/lib/lp/archivepublisher/scripts/sync_signingkeys.py
@@ -186,7 +186,7 @@ class SyncSigningKeysScript(LaunchpadScript):
                 public_key = fd.read()
 
             now = datetime.now().replace(tzinfo=utc)
-            description = u"%s key for %s" % (key_type.name, archive.reference)
+            description = "%s key for %s" % (key_type.name, archive.reference)
             return arch_signing_key_set.inject(
                 key_type, private_key, public_key,
                 description, now, archive,
diff --git a/lib/lp/archivepublisher/signing.py b/lib/lp/archivepublisher/signing.py
index aa3a8c2..5350d07 100644
--- a/lib/lp/archivepublisher/signing.py
+++ b/lib/lp/archivepublisher/signing.py
@@ -329,7 +329,7 @@ class SigningUpload(CustomUpload):
         """
 
         if not self.keyFilesExist(key_type):
-            raise IOError(
+            raise OSError(
                 "Could not fallback to local signing keys: the key files "
                 "were not found.")
         return handler(filename)
@@ -369,7 +369,7 @@ class SigningUpload(CustomUpload):
             if not self.autokey:
                 raise NoSigningKeyError("No signing key for %s" % filename)
             description = (
-                u"%s key for %s" % (key_type.name, self.archive.reference))
+                "%s key for %s" % (key_type.name, self.archive.reference))
             try:
                 signing_key = getUtility(IArchiveSigningKeySet).generate(
                     key_type, description, self.archive).signing_key
@@ -480,7 +480,7 @@ class SigningUpload(CustomUpload):
 
         now = datetime.now().replace(tzinfo=utc)
         description = (
-                u"%s key for %s" % (key_type.name, self.archive.reference))
+                "%s key for %s" % (key_type.name, self.archive.reference))
         key_set.inject(
             key_type, private_key, public_key,
             description, now, self.archive, earliest_distro_series=None)
@@ -715,7 +715,7 @@ class SigningUpload(CustomUpload):
 
         No actual extraction is required.
         """
-        super(SigningUpload, self).extract()
+        super().extract()
         self.setSigningOptions()
         for filename, handler, fallback_handler in self.findSigningHandlers():
             try:
@@ -743,7 +743,7 @@ class SigningUpload(CustomUpload):
         # Avoid circular import.
         from lp.archivepublisher.publishing import DirectoryHash
 
-        super(SigningUpload, self).installFiles(archive, suite)
+        super().installFiles(archive, suite)
 
         versiondir = os.path.join(self.targetdir, self.version)
         with DirectoryHash(versiondir, self.temproot) as hasher:
diff --git a/lib/lp/archivepublisher/tests/test_archivegpgsigningkey.py b/lib/lp/archivepublisher/tests/test_archivegpgsigningkey.py
index 13c698d..15ac59c 100644
--- a/lib/lp/archivepublisher/tests/test_archivegpgsigningkey.py
+++ b/lib/lp/archivepublisher/tests/test_archivegpgsigningkey.py
@@ -66,7 +66,7 @@ class TestSignableArchiveWithSigningKey(TestCaseWithFactory):
 
     @defer.inlineCallbacks
     def setUp(self):
-        super(TestSignableArchiveWithSigningKey, self).setUp()
+        super().setUp()
         self.temp_dir = self.makeTemporaryDirectory()
         self.distro = self.factory.makeDistribution()
         db_pubconf = getUtility(IPublisherConfigSet).getByDistribution(
@@ -202,7 +202,7 @@ class TestSignableArchiveWithRunParts(RunPartsMixin, TestCaseWithFactory):
     layer = ZopelessDatabaseLayer
 
     def setUp(self):
-        super(TestSignableArchiveWithRunParts, self).setUp()
+        super().setUp()
         self.temp_dir = self.makeTemporaryDirectory()
         self.distro = self.factory.makeDistribution()
         db_pubconf = getUtility(IPublisherConfigSet).getByDistribution(
@@ -300,7 +300,7 @@ class TestArchiveGPGSigningKey(TestCaseWithFactory):
 
     @defer.inlineCallbacks
     def setUp(self):
-        super(TestArchiveGPGSigningKey, self).setUp()
+        super().setUp()
         self.temp_dir = self.makeTemporaryDirectory()
         self.pushConfig("personalpackagearchive", root=self.temp_dir)
         self.keyserver = self.useFixture(InProcessKeyServerFixture())
diff --git a/lib/lp/archivepublisher/tests/test_config.py b/lib/lp/archivepublisher/tests/test_config.py
index 85eed68..37a57dc 100644
--- a/lib/lp/archivepublisher/tests/test_config.py
+++ b/lib/lp/archivepublisher/tests/test_config.py
@@ -24,7 +24,7 @@ class TestGetPubConfig(TestCaseWithFactory):
     layer = ZopelessDatabaseLayer
 
     def setUp(self):
-        super(TestGetPubConfig, self).setUp()
+        super().setUp()
         self.ubuntutest = getUtility(IDistributionSet)['ubuntutest']
         self.root = "/var/tmp/archive"
 
@@ -112,7 +112,7 @@ class TestGetPubConfigPPA(TestCaseWithFactory):
     layer = ZopelessDatabaseLayer
 
     def setUp(self):
-        super(TestGetPubConfigPPA, self).setUp()
+        super().setUp()
         self.ubuntutest = getUtility(IDistributionSet)['ubuntutest']
         self.ppa = self.factory.makeArchive(
             distribution=self.ubuntutest, purpose=ArchivePurpose.PPA)
@@ -200,7 +200,7 @@ class TestGetPubConfigPPACompatUefi(TestCaseWithFactory):
     layer = ZopelessDatabaseLayer
 
     def setUp(self):
-        super(TestGetPubConfigPPACompatUefi, self).setUp()
+        super().setUp()
         self.ubuntutest = getUtility(IDistributionSet)['ubuntutest']
         self.ppa = self.factory.makeArchive(
             distribution=self.ubuntutest, purpose=ArchivePurpose.PPA)
diff --git a/lib/lp/archivepublisher/tests/test_customupload.py b/lib/lp/archivepublisher/tests/test_customupload.py
index 6578b76..adae66c 100644
--- a/lib/lp/archivepublisher/tests/test_customupload.py
+++ b/lib/lp/archivepublisher/tests/test_customupload.py
@@ -231,7 +231,7 @@ class TestSigning(TestCaseWithFactory, RunPartsMixin):
     run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=30)
 
     def setUp(self):
-        super(TestSigning, self).setUp()
+        super().setUp()
         self.temp_dir = self.makeTemporaryDirectory()
         self.distro = self.factory.makeDistribution()
         db_pubconf = getUtility(IPublisherConfigSet).getByDistribution(
diff --git a/lib/lp/archivepublisher/tests/test_ddtp_tarball.py b/lib/lp/archivepublisher/tests/test_ddtp_tarball.py
index 1c31fa3..5e196b8 100644
--- a/lib/lp/archivepublisher/tests/test_ddtp_tarball.py
+++ b/lib/lp/archivepublisher/tests/test_ddtp_tarball.py
@@ -27,7 +27,7 @@ class TestDdtpTarball(TestCaseWithFactory):
     layer = ZopelessDatabaseLayer
 
     def setUp(self):
-        super(TestDdtpTarball, self).setUp()
+        super().setUp()
         self.temp_dir = self.makeTemporaryDirectory()
         self.distro = self.factory.makeDistribution()
         db_pubconf = getUtility(IPublisherConfigSet).getByDistribution(
diff --git a/lib/lp/archivepublisher/tests/test_debian_installer.py b/lib/lp/archivepublisher/tests/test_debian_installer.py
index 6ddf57a..d885337 100644
--- a/lib/lp/archivepublisher/tests/test_debian_installer.py
+++ b/lib/lp/archivepublisher/tests/test_debian_installer.py
@@ -33,7 +33,7 @@ class TestDebianInstaller(RunPartsMixin, TestCaseWithFactory):
     layer = ZopelessDatabaseLayer
 
     def setUp(self):
-        super(TestDebianInstaller, self).setUp()
+        super().setUp()
         self.temp_dir = self.makeTemporaryDirectory()
         self.distro = self.factory.makeDistribution()
         db_pubconf = getUtility(IPublisherConfigSet).getByDistribution(
diff --git a/lib/lp/archivepublisher/tests/test_dist_upgrader.py b/lib/lp/archivepublisher/tests/test_dist_upgrader.py
index 6f0bfbe..66a7021 100644
--- a/lib/lp/archivepublisher/tests/test_dist_upgrader.py
+++ b/lib/lp/archivepublisher/tests/test_dist_upgrader.py
@@ -36,7 +36,7 @@ class TestDistUpgrader(RunPartsMixin, TestCaseWithFactory):
     layer = ZopelessDatabaseLayer
 
     def setUp(self):
-        super(TestDistUpgrader, self).setUp()
+        super().setUp()
         self.temp_dir = self.makeTemporaryDirectory()
         self.distro = self.factory.makeDistribution()
         db_pubconf = getUtility(IPublisherConfigSet).getByDistribution(
diff --git a/lib/lp/archivepublisher/tests/test_dominator.py b/lib/lp/archivepublisher/tests/test_dominator.py
index 2b608fe..aefd466 100755
--- a/lib/lp/archivepublisher/tests/test_dominator.py
+++ b/lib/lp/archivepublisher/tests/test_dominator.py
@@ -8,7 +8,6 @@ from functools import cmp_to_key
 from operator import attrgetter
 
 import apt_pkg
-import six
 from testtools.matchers import (
     GreaterThan,
     LessThan,
@@ -814,14 +813,14 @@ class TestDominatorMethods(TestCaseWithFactory):
         # Actually the "oldest to newest" order on the publications only
         # applies to their creation dates.  Their creation orders are
         # irrelevant.
-        for pubs_list in six.itervalues(pubs_by_version):
+        for pubs_list in pubs_by_version.values():
             alter_creation_dates(pubs_list, ages)
             pubs_list.sort(key=attrgetter('datecreated'))
 
         live_versions = ["1.1", "1.2"]
         last_version_alive = sorted(live_versions)[-1]
 
-        all_pubs = sum(six.itervalues(pubs_by_version), [])
+        all_pubs = sum(pubs_by_version.values(), [])
         dominator = Dominator(DevNullLogger(), series.main_archive)
         supersede, _, delete = dominator.planPackageDomination(
             generalization.sortPublications(all_pubs), live_versions,
diff --git a/lib/lp/archivepublisher/tests/test_ftparchive.py b/lib/lp/archivepublisher/tests/test_ftparchive.py
index 1c09bfb..5a1219b 100755
--- a/lib/lp/archivepublisher/tests/test_ftparchive.py
+++ b/lib/lp/archivepublisher/tests/test_ftparchive.py
@@ -85,7 +85,7 @@ class TestFTPArchive(TestCaseWithFactory):
     layer = LaunchpadZopelessLayer
 
     def setUp(self):
-        super(TestFTPArchive, self).setUp()
+        super().setUp()
         switch_dbuser(config.archivepublisher.dbuser)
 
         self._distribution = getUtility(IDistributionSet)['ubuntutest']
@@ -106,7 +106,7 @@ class TestFTPArchive(TestCaseWithFactory):
         self._publisher = SamplePublisher(self._archive)
 
     def tearDown(self):
-        super(TestFTPArchive, self).tearDown()
+        super().tearDown()
         shutil.rmtree(self._config.distroroot)
 
     def _verifyFile(self, filename, directory):
diff --git a/lib/lp/archivepublisher/tests/test_processdeathrow.py b/lib/lp/archivepublisher/tests/test_processdeathrow.py
index d8ffe54..c1bcbd0 100644
--- a/lib/lp/archivepublisher/tests/test_processdeathrow.py
+++ b/lib/lp/archivepublisher/tests/test_processdeathrow.py
@@ -50,7 +50,7 @@ class TestProcessDeathRow(TestCaseWithFactory):
 
     def setUp(self):
         """Set up for a test death row run."""
-        super(TestProcessDeathRow, self).setUp()
+        super().setUp()
         self.setupPrimaryArchive()
         self.setupPPA()
 
@@ -61,7 +61,7 @@ class TestProcessDeathRow(TestCaseWithFactory):
         """Clean up after ourselves."""
         self.tearDownPrimaryArchive()
         self.tearDownPPA()
-        super(TestProcessDeathRow, self).tearDown()
+        super().tearDown()
 
     def setupPrimaryArchive(self):
         """Create pending removal publications in ubuntutest PRIMARY archive.
diff --git a/lib/lp/archivepublisher/tests/test_publisher.py b/lib/lp/archivepublisher/tests/test_publisher.py
index 176044a..6ff8cb2 100644
--- a/lib/lp/archivepublisher/tests/test_publisher.py
+++ b/lib/lp/archivepublisher/tests/test_publisher.py
@@ -141,7 +141,7 @@ class TestPublisherSeries(TestNativePublishingBase):
     """Test the `Publisher` methods that publish individual series."""
 
     def setUp(self):
-        super(TestPublisherSeries, self).setUp()
+        super().setUp()
         self.publisher = None
 
     def _createLinkedPublication(self, name, pocket):
@@ -3025,8 +3025,7 @@ class TestUpdateByHashOverriddenDistsroot(TestUpdateByHash):
         os.rename(original_dists, temporary_dists)
         try:
             self.config.distsroot = temporary_dists
-            super(TestUpdateByHashOverriddenDistsroot, self).runSteps(
-                publisher, **kwargs)
+            super().runSteps(publisher, **kwargs)
         finally:
             self.config.distsroot = original_dists
             os.rename(temporary_dists, original_dists)
@@ -3049,7 +3048,7 @@ class TestPublisherRepositorySignatures(
         """Purge the archive root location. """
         if self.archive_publisher is not None:
             shutil.rmtree(self.archive_publisher._config.distsroot)
-        super(TestPublisherRepositorySignatures, self).tearDown()
+        super().tearDown()
 
     def setupPublisher(self, archive):
         """Setup a `Publisher` instance for the given archive."""
@@ -3327,7 +3326,7 @@ class TestPublisherLite(TestCaseWithFactory):
         purposes, the fake object will compare equal to a string holding
         this same text, encoded in the requested encoding.
         """
-        class FakeReleaseData(six.text_type):
+        class FakeReleaseData(str):
             def dump(self, output_file, encoding):
                 output_file.write(self.encode(encoding))
 
@@ -3421,7 +3420,7 @@ class TestDirectoryHashHelpers(TestCaseWithFactory):
         for dh_file in self.all_hash_files:
             checksum_file = os.path.join(rootdir, dh_file)
             if os.path.exists(checksum_file):
-                with open(checksum_file, "r") as sfd:
+                with open(checksum_file) as sfd:
                     for line in sfd:
                         result[dh_file].append(line.strip().split(' '))
         return result
diff --git a/lib/lp/archivepublisher/tests/test_signing.py b/lib/lp/archivepublisher/tests/test_signing.py
index f6708fd..6746037 100644
--- a/lib/lp/archivepublisher/tests/test_signing.py
+++ b/lib/lp/archivepublisher/tests/test_signing.py
@@ -95,7 +95,7 @@ class SignedMatches(Matcher):
 class FakeMethodCallLog(FakeMethod):
     """Fake execution general commands."""
     def __init__(self, upload=None, *args, **kwargs):
-        super(FakeMethodCallLog, self).__init__(*args, **kwargs)
+        super().__init__(*args, **kwargs)
         self.upload = upload
         self.callers = {
             "UEFI signing": 0,
@@ -114,7 +114,7 @@ class FakeMethodCallLog(FakeMethod):
             }
 
     def __call__(self, *args, **kwargs):
-        super(FakeMethodCallLog, self).__call__(*args, **kwargs)
+        super().__call__(*args, **kwargs)
 
         description = args[0]
         cmdl = args[1]
@@ -189,7 +189,7 @@ class TestSigningHelpers(TestCaseWithFactory):
     run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=30)
 
     def setUp(self):
-        super(TestSigningHelpers, self).setUp()
+        super().setUp()
         self.temp_dir = self.makeTemporaryDirectory()
         self.distro = self.factory.makeDistribution()
         db_pubconf = getUtility(IPublisherConfigSet).getByDistribution(
@@ -1521,7 +1521,7 @@ class TestSigningUploadWithSigningService(TestSigningHelpers):
     layer = ZopelessDatabaseLayer
 
     def setUp(self):
-        super(TestSigningUploadWithSigningService, self).setUp()
+        super().setUp()
         self.useFixture(FeatureFixture({PUBLISHER_USES_SIGNING_SERVICE: True}))
 
         self.signing_service_client = self.useFixture(
@@ -2124,7 +2124,7 @@ class TestSigningUploadWithSigningService(TestSigningHelpers):
         self.assertEqual(1, self.signing_service_client.inject.call_count)
         self.assertEqual(
             (SigningKeyType.OPAL, private_key, public_key,
-             u"OPAL key for %s" % self.archive.reference,
+             "OPAL key for %s" % self.archive.reference,
              now.replace(tzinfo=utc)),
             self.signing_service_client.inject.call_args[0])
 
diff --git a/lib/lp/archivepublisher/tests/test_sync_signingkeys.py b/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
index f99a0ae..9f54f5a 100644
--- a/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
+++ b/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
@@ -64,7 +64,7 @@ class TestSyncSigningKeysScript(TestCaseWithFactory):
     run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=30)
 
     def setUp(self):
-        super(TestSyncSigningKeysScript, self).setUp()
+        super().setUp()
         self.signing_root_dir = self.useFixture(TempDir()).path
         # Add our local configuration to an on-disk configuration file so
         # that it can be used by subprocesses.
@@ -465,7 +465,7 @@ class TestSyncSigningKeysScript(TestCaseWithFactory):
         self.assertEqual(
             (SigningKeyType.UEFI, b"Private key content",
              b"Public key content",
-             u"UEFI key for %s" % archive.reference, now.replace(tzinfo=utc)),
+             "UEFI key for %s" % archive.reference, now.replace(tzinfo=utc)),
             signing_service_client.inject.call_args[0])
 
         with dbuser(config.archivepublisher.dbuser):
@@ -487,7 +487,7 @@ class TestSyncSigningKeysScript(TestCaseWithFactory):
         self.assertEqual(
             (SigningKeyType.UEFI, b"Private key content",
              b"Public key content",
-             u"UEFI key for %s" % archive.reference, now.replace(tzinfo=utc)),
+             "UEFI key for %s" % archive.reference, now.replace(tzinfo=utc)),
             signing_service_client.inject.call_args[0])
 
     def test_inject_existing_key(self):