Bug 1523835 - Added python/mozbuild/mozpack to the flake8 linter and solved the errors, r=ahal
authorkerlyn <kerlynmanyi@gmail.com>
Fri, 01 Mar 2019 15:36:45 -0500
changeset 462307 8a14a69f725a823c03d38ca91c7029cae382a630
parent 462306 962e8a03ecba09cc14ff295977f78a76a6a5aa58
child 462308 00381acd841cf614d823f5864db227d66eef3b46
push id35647
push useraciure@mozilla.com
push dateTue, 05 Mar 2019 04:21:25 +0000
treeherdermozilla-central@c59f0f40e0f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1523835 - Added python/mozbuild/mozpack to the flake8 linter and solved the errors, r=ahal Before this change linting python/mozbuild brought about many errors. Some of this errors could be fixed using |mach lint --fix|. The remaining errors where fixed in this bug. Differential Revision: https://phabricator.services.mozilla.com/D20138
--- a/.flake8
+++ b/.flake8
@@ -20,17 +20,18 @@ exclude =
-    python/mozbuild,
+    python/mozbuild/dumbmake,
+    python/mozbuild/mozbuild,
--- a/python/mozbuild/mozpack/archive.py
+++ b/python/mozbuild/mozpack/archive.py
@@ -79,16 +79,17 @@ def create_tar_gz_from_files(fp, files, 
     gf = gzip.GzipFile(filename=filename or '', mode='wb', fileobj=fp,
                        compresslevel=compresslevel, mtime=DEFAULT_MTIME)
     with gf:
         create_tar_from_files(gf, files)
 class _BZ2Proxy(object):
     """File object that proxies writes to a bz2 compressor."""
     def __init__(self, fp, compresslevel=9):
         self.fp = fp
         self.compressor = bz2.BZ2Compressor(compresslevel=compresslevel)
         self.pos = 0
     def tell(self):
         return self.pos
--- a/python/mozbuild/mozpack/chrome/flags.py
+++ b/python/mozbuild/mozpack/chrome/flags.py
@@ -12,16 +12,17 @@ from collections import OrderedDict
 class Flag(object):
     Class for flags in manifest entries in the form:
         "flag"   (same as "flag=true")
     def __init__(self, name):
         Initialize a Flag with the given name.
         self.name = name
         self.value = None
     def add_definition(self, definition):
@@ -67,16 +68,17 @@ class Flag(object):
 class StringFlag(object):
     Class for string flags in manifest entries in the form:
     def __init__(self, name):
         Initialize a StringFlag with the given name.
         self.name = name
         self.values = []
     def add_definition(self, definition):
@@ -136,16 +138,17 @@ class VersionFlag(object):
     Class for version flags in manifest entries in the form:
     def __init__(self, name):
         Initialize a VersionFlag with the given name.
         self.name = name
         self.values = []
     def add_definition(self, definition):
@@ -232,20 +235,20 @@ class Flags(OrderedDict):
         Initialize a set of flags given in string form.
            flags = Flags('contentaccessible=yes', 'appversion>=3.5')
         for f in flags:
             name = self.RE.split(f)
             name = name[0]
-            if not name in self.FLAGS:
+            if name not in self.FLAGS:
                 errors.fatal('Unknown flag: %s' % name)
-            if not name in self:
+            if name not in self:
                 self[name] = self.FLAGS[name](name)
     def __str__(self):
         Serialize the set of flags.
         return ' '.join(str(self[k]) for k in self)
@@ -255,13 +258,13 @@ class Flags(OrderedDict):
         Return whether the set of flags match the set of given filters.
             flags = Flags('contentaccessible=yes', 'appversion>=3.5',
             flags.match(application='foo') returns True
             flags.match(application='foo', appversion='3.5') returns True
             flags.match(application='foo', appversion='3.0') returns False
         for name, value in filter.iteritems():
-            if not name in self:
+            if name not in self:
             if not self[name].matches(value):
                 return False
         return True
--- a/python/mozbuild/mozpack/chrome/manifest.py
+++ b/python/mozbuild/mozpack/chrome/manifest.py
@@ -50,17 +50,17 @@ class ManifestEntry(object):
         Initialize a manifest entry with the given base path and flags.
         self.base = base
         self.flags = Flags(*flags)
         if not all(f in self.allowed_flags for f in self.flags):
             errors.fatal('%s unsupported for %s manifest entries' %
                          (','.join(f for f in self.flags
-                          if not f in self.allowed_flags), self.type))
+                                   if f not in self.allowed_flags), self.type))
     def serialize(self, *args):
         Serialize the manifest entry.
         entry = [self.type] + list(args)
         flags = str(self.flags)
         if flags:
@@ -91,16 +91,17 @@ class ManifestEntry(object):
         return self.move(base)
 class ManifestEntryWithRelPath(ManifestEntry):
     Abstract manifest entry type with a relative path definition.
     def __init__(self, base, relpath, *flags):
         ManifestEntry.__init__(self, base, *flags)
         self.relpath = relpath
     def __str__(self):
         return self.serialize(self.relpath)
     def rebase(self, base):
@@ -110,31 +111,32 @@ class ManifestEntryWithRelPath(ManifestE
         clone = ManifestEntry.rebase(self, base)
         clone.relpath = mozpath.rebase(self.base, base, self.relpath)
         return clone
     def path(self):
         return mozpath.normpath(mozpath.join(self.base,
-                                                       self.relpath))
+                                             self.relpath))
 class Manifest(ManifestEntryWithRelPath):
     Class for 'manifest' entries.
         manifest some/path/to/another.manifest
     type = 'manifest'
 class ManifestChrome(ManifestEntryWithRelPath):
     Abstract class for chrome entries.
     def __init__(self, base, name, relpath, *flags):
         ManifestEntryWithRelPath.__init__(self, base, relpath, *flags)
         self.name = name
     def location(self):
         return mozpath.join(self.base, self.relpath)
@@ -315,20 +317,21 @@ class ManifestContract(ManifestEntry):
     def __init__(self, base, contractID, cid, *flags):
         ManifestEntry.__init__(self, base, *flags)
         self.contractID = contractID
         self.cid = cid
     def __str__(self):
         return self.serialize(self.contractID, self.cid)
 # All manifest classes by their type name.
 MANIFESTS_TYPES = dict([(c.type, c) for c in globals().values()
-                       if type(c) == type and issubclass(c, ManifestEntry)
-                       and hasattr(c, 'type') and c.type])
+                        if type(c) == type and issubclass(c, ManifestEntry)
+                        and hasattr(c, 'type') and c.type])
 MANIFEST_RE = re.compile(r'^#.*$')
 def parse_manifest_line(base, line):
     Parse a line from a manifest file with the given base directory and
     return the corresponding ManifestEntry instance.
--- a/python/mozbuild/mozpack/copier.py
+++ b/python/mozbuild/mozpack/copier.py
@@ -98,17 +98,17 @@ class FileRegistry(object):
         Remove paths matching the given pattern from the container. See the
         mozpack.path.match documentation for a description of the handled
         items = self.match(pattern)
         if not items:
             return errors.error("Can't remove %s: %s" % (pattern,
-                                "not matching anything previously added"))
+                                                         "not matching anything previously added"))
         for i in items:
             del self._files[i]
     def paths(self):
         Return all paths stored in the container, in the order they were added.
@@ -257,16 +257,17 @@ class FileCopyResult(object):
         return len(self.removed_directories)
 class FileCopier(FileRegistry):
     FileRegistry with the ability to copy the registered files to a separate
     def copy(self, destination, skip_if_older=True,
         Copy all registered files to the given destination path. The given
         destination can be an existing directory, or not exist at all. It
         can't be e.g. a file.
@@ -314,17 +315,17 @@ class FileCopier(FileRegistry):
         # Because we could be handling thousands of files, code in this
         # function is optimized to minimize system calls. We prefer CPU time
         # in Python over possibly I/O bound filesystem calls to stat() and
         # friends.
         required_dirs = set([destination])
         required_dirs |= set(os.path.normpath(os.path.join(destination, d))
-            for d in self.required_directories())
+                             for d in self.required_directories())
         # Ensure destination directories are in place and proper.
         # The "proper" bit is important. We need to ensure that directories
         # have appropriate permissions or we will be unable to discover
         # and write files. Furthermore, we need to verify directories aren't
         # symlinks.
@@ -359,17 +360,17 @@ class FileCopier(FileRegistry):
                 os.chmod(d, 0o777 & ~umask)
         if isinstance(remove_unaccounted, FileRegistry):
             existing_files = set(os.path.normpath(os.path.join(destination, p))
                                  for p in remove_unaccounted.paths())
             existing_dirs = set(os.path.normpath(os.path.join(destination, p))
                                 for p in remove_unaccounted
-                                         .required_directories())
+                                .required_directories())
             existing_dirs |= {os.path.normpath(destination)}
             # While we have remove_unaccounted, it doesn't apply to empty
             # directories because it wouldn't make sense: an empty directory
             # is empty, so removing it should have no effect.
             existing_dirs = set()
             existing_files = set()
             for root, dirs, files in os.walk(destination):
@@ -418,17 +419,17 @@ class FileCopier(FileRegistry):
         copy_results = []
         if sys.platform == 'win32' and len(self) > 100:
             with futures.ThreadPoolExecutor(4) as e:
                 fs = []
                 for p, f in self:
                     destfile = os.path.normpath(os.path.join(destination, p))
                     fs.append((destfile, e.submit(f.copy, destfile, skip_if_older)))
-            copy_results = [(destfile, f.result) for destfile, f in fs]
+            copy_results = [(path, f.result) for path, f in fs]
             for p, f in self:
                 destfile = os.path.normpath(os.path.join(destination, p))
                 copy_results.append((destfile, f.copy(destfile, skip_if_older)))
         for destfile, copy_result in copy_results:
             if copy_result:
@@ -502,16 +503,17 @@ class FileCopier(FileRegistry):
         return result
 class Jarrer(FileRegistry, BaseFile):
     FileRegistry with the ability to copy and pack the registered files as a
     jar file. Also acts as a BaseFile instance, to be copied with a FileCopier.
     def __init__(self, compress=True):
         Create a Jarrer instance. See mozpack.mozjar.JarWriter documentation
         for details on the compress argument.
         self.compress = compress
         self._preload = []
         self._compress_options = {}  # Map path to compress boolean option.
@@ -535,16 +537,17 @@ class Jarrer(FileRegistry, BaseFile):
             Dest-like class, reading from a file-like object initially, but
             switching to a Deflater object if written to.
                 dest = DeflaterDest(original_file)
                 dest.read()      # Reads original_file
                 dest.write(data) # Creates a Deflater and write data there
                 dest.read()      # Re-opens the Deflater and reads from it
             def __init__(self, orig=None, compress=True):
                 self.mode = None
                 self.deflater = orig
                 self.compress = compress
             def read(self, length=-1):
                 if self.mode != 'r':
                     assert self.mode is None
--- a/python/mozbuild/mozpack/executables.py
+++ b/python/mozbuild/mozpack/executables.py
@@ -19,16 +19,17 @@ MACHO_SIGNATURES = [
 FAT_SIGNATURE = 0xcafebabe  # mach-o FAT binary
 ELF_SIGNATURE = 0x7f454c46  # Elf binary
 MACHO = 1
 ELF = 2
 def get_type(path):
     Check the signature of the give file and returns what kind of executable
     with open(path, 'rb') as f:
         signature = f.read(4)
         if len(signature) < 4:
@@ -103,18 +104,18 @@ def strip(path):
 def may_elfhack(path):
     Return whether elfhack() should be called
     # elfhack only supports libraries. We should check the ELF header for
     # the right flag, but checking the file extension works too.
     from buildconfig import substs
     return ('USE_ELF_HACK' in substs and substs['USE_ELF_HACK'] and
-        path.endswith(substs['DLL_SUFFIX']) and
-        'COMPILE_ENVIRONMENT' in substs and substs['COMPILE_ENVIRONMENT'])
+            path.endswith(substs['DLL_SUFFIX']) and
+            'COMPILE_ENVIRONMENT' in substs and substs['COMPILE_ENVIRONMENT'])
 def elfhack(path):
     Execute the elfhack command on the given path.
     from buildconfig import topobjdir
     cmd = [os.path.join(topobjdir, 'build/unix/elfhack/elfhack'), path]
@@ -126,17 +127,17 @@ def elfhack(path):
 def xz_compress(path):
     Execute xz to compress the given path.
     if open(path, 'rb').read(5)[1:] == '7zXZ':
         print('%s is already compressed' % path)
     from buildconfig import substs
     xz = substs.get('XZ')
     cmd = [xz, '-zkf', path]
     # For now, the mozglue XZStream ELF loader can only support xz files
     # with a single stream that contains a single block. In xz, there is no
     # explicit option to set the max block count. Instead, we force xz to use
     # single thread mode, which results in a single block.
--- a/python/mozbuild/mozpack/files.py
+++ b/python/mozbuild/mozpack/files.py
@@ -65,26 +65,28 @@ else:
         # False indicates `dest` should be overwritten if it exists already.
         if isinstance(src, unicode) and isinstance(dest, unicode):
             _CopyFileW(src, dest, False)
         elif isinstance(src, str) and isinstance(dest, str):
             _CopyFileA(src, dest, False)
             raise TypeError('mismatched path types!')
 class Dest(object):
     Helper interface for BaseFile.copy. The interface works as follows:
     - read() and write() can be used to sequentially read/write from the
       underlying file.
     - a call to read() after a write() will re-open the underlying file and
       read from it.
     - a call to write() after a read() will re-open the underlying file,
       emptying it, and write to it.
     def __init__(self, path):
         self.path = path
         self.mode = None
     def name(self):
         return self.path
@@ -121,17 +123,17 @@ class BaseFile(object):
         Compares the modification time of two files, and returns whether the
         ``first`` file is older than the ``second`` file.
         # os.path.getmtime returns a result in seconds with precision up to
         # the microsecond. But microsecond is too precise because
         # shutil.copystat only copies milliseconds, and seconds is not
         # enough precision.
         return int(os.path.getmtime(first) * 1000) \
-                <= int(os.path.getmtime(second) * 1000)
+            <= int(os.path.getmtime(second) * 1000)
     def any_newer(dest, inputs):
         Compares the modification time of ``dest`` to multiple input files, and
         returns whether any of the ``inputs`` is newer (has a later mtime) than
@@ -150,17 +152,17 @@ class BaseFile(object):
         # Normalize file mode:
         # - keep file type (e.g. S_IFREG)
         ret = stat.S_IFMT(mode)
         # - expand user read and execute permissions to everyone
         if mode & 0o0400:
             ret |= 0o0444
         if mode & 0o0100:
             ret |= 0o0111
-         # - keep user write permissions
+        # - keep user write permissions
         if mode & 0o0200:
             ret |= 0o0200
         # - leave away sticky bit, setuid, setgid
         return ret
     def copy(self, dest, skip_if_older=True):
         Copy the BaseFile content to the destination given as a string or a
@@ -246,16 +248,17 @@ class BaseFile(object):
         raise NotImplementedError('BaseFile.inputs() not implemented.')
 class File(BaseFile):
     File class for plain files.
     def __init__(self, path):
         self.path = path
     def mode(self):
         Return the file's unix mode, as returned by os.stat().st_mode.
@@ -277,16 +280,17 @@ class File(BaseFile):
         return (self.path,)
 class ExecutableFile(File):
     File class for executable and library files on OS/2, OS/X and ELF systems.
     (see mozpack.executables.is_executable documentation).
     def __init__(self, path, xz_compress=False):
         File.__init__(self, path)
         self.xz_compress = xz_compress
     def copy(self, dest, skip_if_older=True):
         real_dest = dest
         if not isinstance(dest, basestring):
             fd, dest = mkstemp()
@@ -474,41 +478,43 @@ class ExistingFile(BaseFile):
     When asked to copy, this class does nothing because nothing is known about
     the source file/data.
     Instances of this class come in two flavors: required and optional. If an
     existing file is required, it must exist during copy() or an error is
     def __init__(self, required):
         self.required = required
     def copy(self, dest, skip_if_older=True):
         if isinstance(dest, basestring):
             dest = Dest(dest)
             assert isinstance(dest, Dest)
         if not self.required:
         if not dest.exists():
             errors.fatal("Required existing file doesn't exist: %s" %
-                dest.path)
+                         dest.path)
     def inputs(self):
         return ()
 class PreprocessedFile(BaseFile):
     File class for a file that is preprocessed. PreprocessedFile.copy() runs
     the preprocessor on the file to create the output.
     def __init__(self, path, depfile_path, marker, defines, extra_depends=None,
         self.path = path
         self.depfile = depfile_path
         self.marker = marker
         self.defines = defines
         self.extra_depends = list(extra_depends or [])
         self.silence_missing_directive_warnings = \
@@ -583,16 +589,17 @@ class PreprocessedFile(BaseFile):
         return True
 class GeneratedFile(BaseFile):
     File class for content with no previous existence on the filesystem.
     def __init__(self, content):
         self._content = content
     def content(self):
         if inspect.isfunction(self._content):
             self._content = self._content()
         return self._content
@@ -614,58 +621,63 @@ class GeneratedFile(BaseFile):
         return ()
 class DeflatedFile(BaseFile):
     File class for members of a jar archive. DeflatedFile.copy() effectively
     extracts the file from the jar archive.
     def __init__(self, file):
         from mozpack.mozjar import JarFileReader
         assert isinstance(file, JarFileReader)
         self.file = file
     def open(self):
         return self.file
 class ExtractedTarFile(GeneratedFile):
     File class for members of a tar archive. Contents of the underlying file
     are extracted immediately and stored in memory.
     def __init__(self, tar, info):
         assert isinstance(info, TarInfo)
         assert isinstance(tar, TarFile)
         GeneratedFile.__init__(self, tar.extractfile(info).read())
         self._mode = self.normalize_mode(info.mode)
     def mode(self):
         return self._mode
     def read(self):
         return self.content
 class ManifestFile(BaseFile):
     File class for a manifest file. It takes individual manifest entries (using
     the add() and remove() member functions), and adjusts them to be relative
     to the base path for the manifest, given at creation.
         There is a manifest entry "content foobar foobar/content/" relative
         to "foobar/chrome". When packaging, the entry will be stored in
         jar:foobar/omni.ja!/chrome/chrome.manifest, which means the entry
         will have to be relative to "chrome" instead of "foobar/chrome". This
         doesn't really matter when serializing the entry, since this base path
         is not written out, but it matters when moving the entry at the same
         time, e.g. to jar:foobar/omni.ja!/chrome.manifest, which we don't do
         currently but could in the future.
     def __init__(self, base, entries=None):
         self._base = base
         self._entries = []
         self._interfaces = []
         for e in entries or []:
     def add(self, entry):
@@ -711,16 +723,17 @@ class ManifestFile(BaseFile):
         return len(self._entries) + len(self._interfaces) == 0
 class MinifiedProperties(BaseFile):
     File class for minified properties. This wraps around a BaseFile instance,
     and removes lines starting with a # from its content.
     def __init__(self, file):
         assert isinstance(file, BaseFile)
         self._file = file
     def open(self):
         Return a file-like object allowing to read() the minified content of
         the properties file.
@@ -728,16 +741,17 @@ class MinifiedProperties(BaseFile):
         return BytesIO(''.join(l for l in self._file.open().readlines()
                                if not l.startswith('#')))
 class MinifiedJavaScript(BaseFile):
     File class for minifying JavaScript files.
     def __init__(self, file, verify_command=None):
         assert isinstance(file, BaseFile)
         self._file = file
         self._verify_command = verify_command
     def open(self):
         output = BytesIO()
         minify = JavascriptMinify(self._file.open(), output, quote_chars="'\"`")
@@ -757,30 +771,30 @@ class MinifiedJavaScript(BaseFile):
                 args = list(self._verify_command)
                 args.extend([fh1.name, fh2.name])
                 subprocess.check_output(args, stderr=subprocess.STDOUT)
             except subprocess.CalledProcessError as e:
                 errors.warn('JS minification verification failed for %s:' %
-                    (getattr(self._file, 'path', '<unknown>')))
+                            (getattr(self._file, 'path', '<unknown>')))
                 # Prefix each line with "Warning:" so mozharness doesn't
                 # think these error messages are real errors.
                 for line in e.output.splitlines():
                 return self._file.open()
         return output
 class BaseFinder(object):
     def __init__(self, base, minify=False, minify_js=False,
-        minify_js_verify_command=None):
+                 minify_js_verify_command=None):
         Initializes the instance with a reference base directory.
         The optional minify argument specifies whether minification of code
         should occur. minify_js is an additional option to control minification
         of JavaScript. It requires minify to be True.
         minify_js_verify_command can be used to optionally verify the results
@@ -890,16 +904,17 @@ class BaseFinder(object):
                 if mozpath.basedir(p, [pattern]) == pattern:
                     yield p, file_getter(p)
 class FileFinder(BaseFinder):
     Helper to get appropriate BaseFile instances from the file system.
     def __init__(self, base, find_executables=False, ignore=(),
                  find_dotfiles=False, **kargs):
         Create a FileFinder for files under the given base directory.
         The find_executables argument determines whether the finder needs to
         try to guess whether files are executables. Disabling this guessing
         when not necessary can speed up the finder significantly.
@@ -1005,16 +1020,17 @@ class FileFinder(BaseFinder):
                 yield p, f
 class JarFinder(BaseFinder):
     Helper to get appropriate DeflatedFile instances from a JarReader.
     def __init__(self, base, reader, **kargs):
         Create a JarFinder for files in the given JarReader. The base argument
         is used as an indication of the Jar file location.
         assert isinstance(reader, JarReader)
         BaseFinder.__init__(self, base, **kargs)
         self._files = OrderedDict((f.filename, f) for f in reader)
@@ -1027,16 +1043,17 @@ class JarFinder(BaseFinder):
         return self._find_helper(pattern, self._files,
                                  lambda x: DeflatedFile(self._files[x]))
 class TarFinder(BaseFinder):
     Helper to get files from a TarFile.
     def __init__(self, base, tar, **kargs):
         Create a TarFinder for files in the given TarFile. The base argument
         is used as an indication of the Tar file location.
         assert isinstance(tar, TarFile)
         self._tar = tar
         BaseFinder.__init__(self, base, **kargs)
@@ -1057,16 +1074,17 @@ class ComposedFinder(BaseFinder):
     Composes multiple File Finders in some sort of virtual file system.
     A ComposedFinder is initialized from a dictionary associating paths to
     *Finder instances.
     Note this could be optimized to be smarter than getting all the files
     in advance.
     def __init__(self, finders):
         # Can't import globally, because of the dependency of mozpack.copier
         # on this module.
         from mozpack.copier import FileRegistry
         self.files = FileRegistry()
         for base, finder in sorted(finders.iteritems()):
             if self.files.contains(base):
@@ -1076,16 +1094,17 @@ class ComposedFinder(BaseFinder):
     def find(self, pattern):
         for p in self.files.match(pattern):
             yield p, self.files[p]
 class MercurialFile(BaseFile):
     """File class for holding data from Mercurial."""
     def __init__(self, client, rev, path):
         self._content = client.cat([path], rev=rev)
     def read(self):
         return self._content
 class MercurialRevisionFinder(BaseFinder):
--- a/python/mozbuild/mozpack/manifests.py
+++ b/python/mozbuild/mozpack/manifests.py
@@ -119,17 +119,17 @@ class InstallManifest(object):
             with _auto_fileobj(path, fileobj, 'rb') as fh:
     def _load_from_fileobj(self, fileobj):
         version = fileobj.readline().rstrip()
         if version not in ('1', '2', '3', '4', '5'):
             raise UnreadableInstallManifest('Unknown manifest version: %s' %
-                version)
+                                            version)
         for line in fileobj:
             line = line.rstrip()
             fields = line.split(self.FIELD_SEPARATOR)
             record_type = int(fields[0])
@@ -162,32 +162,32 @@ class InstallManifest(object):
                 _, base, pattern, dest = fields[1:]
                 self.add_pattern_copy(base, pattern, dest)
             if record_type == self.PREPROCESS:
                 dest, source, deps, marker, defines, warnings = fields[1:]
                 self.add_preprocess(source, dest, deps, marker,
-                    self._decode_field_entry(defines),
-                    silence_missing_directive_warnings=bool(int(warnings)))
+                                    self._decode_field_entry(defines),
+                                    silence_missing_directive_warnings=bool(int(warnings)))
             if record_type == self.CONTENT:
                 dest, content = fields[1:]
                     self._decode_field_entry(content).encode('utf-8'), dest)
             # Don't fail for non-actionable items, allowing
             # forward-compatibility with those we will add in the future.
             if record_type >= 0:
                 raise UnreadableInstallManifest('Unknown record type: %d' %
-                    record_type)
+                                                record_type)
     def __len__(self):
         return len(self._dests)
     def __contains__(self, item):
         return item in self._dests
     def __eq__(self, other):
@@ -289,25 +289,25 @@ class InstallManifest(object):
         under ``dest``.
         Filenames under ``dest`` are constructed by taking the path fragment
         after ``base`` and concatenating it with ``dest``. e.g.
            <base>/foo/bar.h -> <dest>/foo/bar.h
         self._add_entry(mozpath.join(dest, pattern),
-            (self.PATTERN_LINK, base, pattern, dest))
+                        (self.PATTERN_LINK, base, pattern, dest))
     def add_pattern_copy(self, base, pattern, dest):
         """Add a pattern match that results in copies.
         See ``add_pattern_link()`` for usage.
         self._add_entry(mozpath.join(dest, pattern),
-            (self.PATTERN_COPY, base, pattern, dest))
+                        (self.PATTERN_COPY, base, pattern, dest))
     def add_preprocess(self, source, dest, deps, marker='#', defines={},
         """Add a preprocessed file to this manifest.
         ``source`` will be passed through preprocessor.py, and the output will be
         written to ``dest``.
@@ -422,26 +422,28 @@ class InstallManifest(object):
                     registry.add(mozpath.join(dest, path), cls(source))
             if install_type == self.PREPROCESS:
                 defines = self._decode_field_entry(entry[4])
                 if defines_override:
-                registry.add(dest, PreprocessedFile(entry[1],
-                    depfile_path=entry[2],
-                    marker=entry[3],
-                    defines=defines,
-                    extra_depends=self._source_files,
-                    silence_missing_directive_warnings=bool(int(entry[5]))))
+                registry.add(dest, PreprocessedFile(
+                   entry[1],
+                   depfile_path=entry[2],
+                   marker=entry[3],
+                   defines=defines,
+                   extra_depends=self._source_files,
+                   silence_missing_directive_warnings=bool(int(entry[5])),
+                ))
             if install_type == self.CONTENT:
                 # GeneratedFile expect the buffer interface, which the unicode
                 # type doesn't have, so encode to a str.
                 content = self._decode_field_entry(entry[1]).encode('utf-8')
                 registry.add(dest, GeneratedFile(content))
             raise Exception('Unknown install type defined in manifest: %d' %
-                install_type)
+                            install_type)
--- a/python/mozbuild/mozpack/mozjar.py
+++ b/python/mozbuild/mozpack/mozjar.py
@@ -68,17 +68,17 @@ class JarStruct(object):
     def __init__(self, data=None):
         Create an instance from the given data. Data may be omitted to create
         an instance with empty fields.
         assert self.MAGIC and isinstance(self.STRUCT, OrderedDict)
         self.size_fields = set(t for t in self.STRUCT.itervalues()
-                               if not t in JarStruct.TYPE_MAPPING)
+                               if t not in JarStruct.TYPE_MAPPING)
         self._values = {}
         if data:
     def _init_data(self, data):
@@ -97,17 +97,17 @@ class JarStruct(object):
         for name, t in self.STRUCT.iteritems():
             if t in JarStruct.TYPE_MAPPING:
                 value, size = JarStruct.get_data(t, data[offset:])
                 size = sizes[t]
                 value = data[offset:offset + size]
                 if isinstance(value, memoryview):
                     value = value.tobytes()
-            if not name in sizes:
+            if name not in sizes:
                 self._values[name] = value
                 sizes[name] = value
             offset += size
     def _init_empty(self):
         Initialize an instance with empty fields.
@@ -134,17 +134,17 @@ class JarStruct(object):
     def serialize(self):
         Serialize the data structure according to the data structure definition
         from self.STRUCT.
         serialized = struct.pack('<I', self.signature)
         sizes = dict((t, name) for name, t in self.STRUCT.iteritems()
-                     if not t in JarStruct.TYPE_MAPPING)
+                     if t not in JarStruct.TYPE_MAPPING)
         for name, t in self.STRUCT.iteritems():
             if t in JarStruct.TYPE_MAPPING:
                 format, size = JarStruct.TYPE_MAPPING[t]
                 if name in sizes:
                     value = len(self[sizes[name]])
                     value = self[name]
                 serialized += struct.pack('<' + format, value)
@@ -165,17 +165,17 @@ class JarStruct(object):
                 size += len(self[name])
         return size
     def __getitem__(self, key):
         return self._values[key]
     def __setitem__(self, key, value):
-        if not key in self.STRUCT:
+        if key not in self.STRUCT:
             raise KeyError(key)
         if key in self.size_fields:
             raise AttributeError("can't set attribute")
         self._values[key] = value
     def __contains__(self, key):
         return key in self._values
@@ -198,16 +198,17 @@ class JarCdirEnd(JarStruct):
         ('disk_entries', 'uint16'),
         ('cdir_entries', 'uint16'),
         ('cdir_size', 'uint32'),
         ('cdir_offset', 'uint32'),
         ('comment_size', 'uint16'),
         ('comment', 'comment_size'),
 CDIR_END_SIZE = JarCdirEnd().size
 class JarCdirEntry(JarStruct):
     Central directory file header
     MAGIC = 0x02014b50
@@ -255,16 +256,17 @@ class JarLocalFileHeader(JarStruct):
 class JarFileReader(object):
     File-like class for use by JarReader to give access to individual files
     within a Jar archive.
     def __init__(self, header, data):
         Initialize a JarFileReader. header is the local file header
         corresponding to the file in the jar archive, data a buffer containing
         the file data.
         assert header['compression'] in [JAR_DEFLATED, JAR_STORED, JAR_BROTLI]
         self._data = data
@@ -336,16 +338,17 @@ class JarFileReader(object):
         return self._uncompressed_data
 class JarReader(object):
     Class with methods to read Jar files. Can open standard jar files as well
     as Mozilla jar files (see further details in the JarWriter documentation).
     def __init__(self, file=None, fileobj=None, data=None):
         Opens the given file as a Jar archive. Use the given file-like object
         if one is given instead of opening the given file name.
         if fileobj:
             data = fileobj.read()
         elif file:
@@ -469,16 +472,17 @@ class JarReader(object):
 class JarWriter(object):
     Class with methods to write Jar files. Can write more-or-less standard jar
     archives as well as jar archives optimized for Gecko. See the documentation
     for the close() member function for a description of both layouts.
     def __init__(self, file=None, fileobj=None, compress=True, compress_level=9):
         Initialize a Jar archive in the given file. Use the given file-like
         object if one is given instead of opening the given file name.
         The compress option determines the default behavior for storing data
         in the jar archive. The optimize options determines whether the jar
         archive should be optimized for Gecko or not. ``compress_level``
         defines the zlib compression level. It must be a value between 0 and 9
@@ -609,17 +613,17 @@ class JarWriter(object):
         if name in self._contents and not skip_duplicates:
             raise JarWriterError("File %s already in JarWriter" % name)
         if compress is None:
             compress = self._compress
         if compress is True:
             compress = JAR_DEFLATED
         if compress is False:
             compress = JAR_STORED
-        if (isinstance(data, (JarFileReader, Deflater)) and \
+        if (isinstance(data, (JarFileReader, Deflater)) and
                 data.compress == compress):
             deflater = data
             deflater = Deflater(compress, compress_level=self._compress_level)
             if isinstance(data, basestring):
             elif hasattr(data, 'read'):
                 if hasattr(data, 'seek'):
@@ -656,32 +660,33 @@ class JarWriter(object):
     def preload(self, files):
         Set which members of the jar archive should be preloaded when opening
         the archive in Gecko. This reorders the members according to the order
         of given list.
         new_contents = OrderedDict()
         for f in files:
-            if not f in self._contents:
+            if f not in self._contents:
             new_contents[f] = self._contents[f]
             self._last_preloaded = f
         for f in self._contents:
-            if not f in new_contents:
+            if f not in new_contents:
                 new_contents[f] = self._contents[f]
         self._contents = new_contents
 class Deflater(object):
     File-like interface to zlib compression. The data is actually not
     compressed unless the compressed form is smaller than the uncompressed
     def __init__(self, compress=True, compress_level=9):
         Initialize a Deflater. The compress argument determines how to
         self._data = BytesIO()
         if compress is True:
             compress = JAR_DEFLATED
@@ -784,19 +789,19 @@ class Deflater(object):
             return self._deflated.getvalue()
         return self._data.getvalue()
 class Brotli(object):
     def brotli_tool():
-            from buildconfig import topobjdir, substs
-            return os.path.join(topobjdir, 'dist', 'host', 'bin',
-                               'bro' + substs.get('BIN_SUFFIX', ''))
+        from buildconfig import topobjdir, substs
+        return os.path.join(topobjdir, 'dist', 'host', 'bin',
+                            'bro' + substs.get('BIN_SUFFIX', ''))
     def run_brotli_tool(args, input):
         proc = subprocess.Popen([Brotli.brotli_tool()] + args,
         (stdout, _) = proc.communicate(input)
         ret = proc.wait()
@@ -808,17 +813,16 @@ class Brotli(object):
     def compress(data):
         return Brotli.run_brotli_tool(['--window', '17'], data)
     def decompress(data):
         return Brotli.run_brotli_tool(['--decompress'], data)
 class BrotliCompress(object):
     def __init__(self):
         self._buf = BytesIO()
     def compress(self, data):
         return b''
@@ -829,16 +833,17 @@ class BrotliCompress(object):
 class JarLog(dict):
     Helper to read the file Gecko generates when setting MOZ_JAR_LOG_FILE.
     The jar log is then available as a dict with the jar path as key (see
     canonicalize for more details on the key value), and the corresponding
     access log as a list value. Only the first access to a given member of
     a jar is stored.
     def __init__(self, file=None, fileobj=None):
         if not fileobj:
             fileobj = open(file, 'r')
         urlmap = {}
         for line in fileobj:
             url, path = line.strip().split(None, 1)
             if not url or not path:
--- a/python/mozbuild/mozpack/packager/__init__.py
+++ b/python/mozbuild/mozpack/packager/__init__.py
@@ -23,20 +23,20 @@ import mozpack.path as mozpath
 from collections import deque
 import json
 class Component(object):
     Class that represents a component in a package manifest.
     def __init__(self, name, destdir='', xz_compress=False):
         if name.find(' ') > 0:
-            errors.fatal('Malformed manifest: space in component name "%s"'
-                         % component)
+            errors.fatal('Malformed manifest: space in component name "%s"' % name)
         self._name = name
         self._destdir = destdir
         self._xz_compress = xz_compress
     def __repr__(self):
         s = self.name
         if self.destdir:
             s += ' destdir="%s"' % self.destdir
@@ -146,16 +146,17 @@ class PackageManifestParser(object):
         ; file comment
     The parser takes input from the preprocessor line by line, and pushes
     parsed information to a sink object.
     The add and remove methods of the sink object are called with the
     current Component instance and a path.
     def __init__(self, sink):
         Initialize the package manifest parser with the given sink.
         self._component = Component('')
         self._sink = sink
     def handle_line(self, str):
@@ -178,16 +179,17 @@ class PackageManifestParser(object):
             self._sink.add(self._component, str)
 class PreprocessorOutputWrapper(object):
     File-like helper to handle the preprocessor output and send it to a parser.
     The parser's handle_line method is called in the relevant errors.context.
     def __init__(self, preprocessor, parser):
         self._parser = parser
         self._pp = preprocessor
     def write(self, str):
         with errors.context(self._pp.context['FILE'], self._pp.context['LINE']):
@@ -212,16 +214,17 @@ def preprocess_manifest(sink, manifest, 
     preprocess(manifest, PackageManifestParser(sink), defines)
 class CallDeque(deque):
     Queue of function calls to make.
     def append(self, function, *args):
         deque.append(self, (errors.get_context(), function, args))
     def execute(self):
         while True:
                 context, function, args = self.popleft()
             except IndexError:
@@ -235,16 +238,17 @@ class CallDeque(deque):
 class SimplePackager(object):
     Helper used to translate and buffer instructions from the
     SimpleManifestSink to a formatter. Formatters expect some information to be
     given first that the simple manifest contents can't guarantee before the
     end of the input.
     def __init__(self, formatter):
         self.formatter = formatter
         # Queue for formatter.add_interfaces()/add_manifest() calls.
         self._queue = CallDeque()
         # Queue for formatter.add_manifest() calls for ManifestChrome.
         self._chrome_queue = CallDeque()
         # Queue for formatter.add() calls.
         self._file_queue = CallDeque()
@@ -282,29 +286,29 @@ class SimplePackager(object):
                     addon = 'unpacked'
                 self._add_addon(mozpath.dirname(path), addon)
             elif mozpath.basename(path) == 'manifest.json':
                 manifest = file.open().read()
                     parsed = json.loads(manifest)
                 except ValueError:
-                if isinstance(parsed, dict) and parsed.has_key('manifest_version'):
+                if isinstance(parsed, dict) and 'manifest_version' in parsed:
                     self._add_addon(mozpath.dirname(path), True)
     def _add_addon(self, path, addon_type):
         Add the given BaseFile to the collection of addons if a parent
         directory is not already in the collection.
-        if mozpath.basedir(path, self._addons) != None:
+        if mozpath.basedir(path, self._addons) is not None:
         for dir in self._addons:
-            if mozpath.basedir(dir, [path]) != None:
+            if mozpath.basedir(dir, [path]) is not None:
                 del self._addons[dir]
         self._addons[path] = addon_type
     def _add_manifest_file(self, path, file):
         Add the given BaseFile with manifest file contents with the given path.
@@ -340,17 +344,17 @@ class SimplePackager(object):
     def get_bases(self, addons=True):
         Return all paths under which root manifests have been found. Root
         manifests are manifests that are included in no other manifest.
         `addons` indicates whether to include addon bases as well.
         all_bases = set(mozpath.dirname(m)
                         for m in self._manifests
-                                 - set(self._included_manifests))
+                        - set(self._included_manifests))
         if not addons:
             all_bases -= set(self._addons)
             # If for some reason some detected addon doesn't have a
             # non-included manifest.
             all_bases |= set(self._addons)
         return all_bases
@@ -379,16 +383,17 @@ class SimpleManifestSink(object):
     Parser sink for "simple" package manifests. Simple package manifests use
     the format described in the PackageManifestParser documentation, but don't
     support file removals, and require manifests, interfaces and chrome data to
     be explicitely listed.
     Entries starting with bin/ are searched under bin/ in the FileFinder, but
     are packaged without the bin/ prefix.
     def __init__(self, finder, formatter):
         Initialize the SimpleManifestSink. The given FileFinder is used to
         get files matching the patterns given in the manifest. The given
         formatter does the packaging job.
         self._finder = finder
         self.packager = SimplePackager(formatter)
@@ -433,12 +438,12 @@ class SimpleManifestSink(object):
         Add possibly missing bits and push all instructions to the formatter.
         if auto_root_manifest:
             # Simple package manifests don't contain the root manifests, so
             # find and add them.
             paths = [mozpath.dirname(m) for m in self._manifests]
             path = mozpath.dirname(mozpath.commonprefix(paths))
             for p, f in self._finder.find(mozpath.join(path,
-                                          'chrome.manifest')):
-                if not p in self._manifests:
+                                                       'chrome.manifest')):
+                if p not in self._manifests:
                     self.packager.add(SimpleManifestSink.normalize_path(p), f)
--- a/python/mozbuild/mozpack/packager/formats.py
+++ b/python/mozbuild/mozpack/packager/formats.py
@@ -1,17 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 from __future__ import absolute_import
 from mozpack.chrome.manifest import (
-    ManifestEntryWithRelPath,
 from mozpack.errors import errors
 from urlparse import urlparse
@@ -62,16 +61,17 @@ data.
 class PiecemealFormatter(object):
     Generic formatter that dispatches across different sub-formatters
     according to paths.
     def __init__(self, copier):
         assert isinstance(copier, (FileRegistry, FileRegistrySubtree))
         self.copier = copier
         self._sub_formatter = {}
         self._frozen_bases = False
     def add_base(self, base, addon=False):
         # Only allow to add a base directory before calls to _get_base()
@@ -111,25 +111,27 @@ class PiecemealFormatter(object):
             return self.copier.contains(relpath)
         return self._sub_formatter[base].contains(relpath)
 class FlatFormatter(PiecemealFormatter):
     Formatter for the flat package format.
     def _add_base(self, base, addon=False):
         self._sub_formatter[base] = FlatSubFormatter(
             FileRegistrySubtree(base, self.copier))
 class FlatSubFormatter(object):
     Sub-formatter for the flat package format.
     def __init__(self, copier):
         assert isinstance(copier, (FileRegistry, FileRegistrySubtree))
         self.copier = copier
         self._chrome_db = {}
     def add(self, path, content):
         self.copier.add(path, content)
@@ -144,17 +146,17 @@ class FlatSubFormatter(object):
         path = mozpath.normpath(mozpath.join(entry.base, '%s.manifest' % name))
         if not self.copier.contains(path):
             # Add a reference to the manifest file in the parent manifest, if
             # the manifest file is not a root manifest.
             if entry.base:
                 parent = mozpath.dirname(entry.base)
                 relbase = mozpath.basename(entry.base)
                 relpath = mozpath.join(relbase,
-                                            mozpath.basename(path))
+                                       mozpath.basename(path))
                 self.add_manifest(Manifest(parent, relpath))
             self.copier.add(path, ManifestFile(entry.base))
         if isinstance(entry, ManifestChrome):
             data = self._chrome_db.setdefault(entry.name, {})
             if isinstance(entry, ManifestMultiContent):
                 entries = data.setdefault(entry.type, {}) \
                               .setdefault(entry.id, [])
@@ -185,19 +187,20 @@ class FlatSubFormatter(object):
 class JarFormatter(PiecemealFormatter):
     Formatter for the jar package format. Assumes manifest entries related to
     chrome are registered before the chrome data files are added. Also assumes
     manifest entries for resources are registered after chrome manifest
     def __init__(self, copier, compress=True):
         PiecemealFormatter.__init__(self, copier)
-        self._compress=compress
+        self._compress = compress
     def _add_base(self, base, addon=False):
         if addon is True:
             jarrer = Jarrer(self._compress)
             self.copier.add(base + '.xpi', jarrer)
             self._sub_formatter[base] = FlatSubFormatter(jarrer)
             self._sub_formatter[base] = JarSubFormatter(
@@ -207,16 +210,17 @@ class JarFormatter(PiecemealFormatter):
 class JarSubFormatter(PiecemealFormatter):
     Sub-formatter for the jar package format. It is a PiecemealFormatter that
     dispatches between further sub-formatter for each of the jar files it
     dispatches the chrome data to, and a FlatSubFormatter for the non-chrome
     def __init__(self, copier, compress=True):
         PiecemealFormatter.__init__(self, copier)
         self._frozen_chrome = False
         self._compress = compress
         self._sub_formatter[''] = FlatSubFormatter(copier)
     def _jarize(self, entry, relpath):
@@ -247,16 +251,17 @@ class JarSubFormatter(PiecemealFormatter
                 entry = new_entry
         PiecemealFormatter.add_manifest(self, entry)
 class OmniJarFormatter(JarFormatter):
     Formatter for the omnijar package format.
     def __init__(self, copier, omnijar_name, compress=True, non_resources=()):
         JarFormatter.__init__(self, copier, compress)
         self._omnijar_name = omnijar_name
         self._non_resources = non_resources
     def _add_base(self, base, addon=False):
         if addon:
             JarFormatter._add_base(self, base, addon)
@@ -272,16 +277,17 @@ class OmniJarFormatter(JarFormatter):
 class OmniJarSubFormatter(PiecemealFormatter):
     Sub-formatter for the omnijar package format. It is a PiecemealFormatter
     that dispatches between a FlatSubFormatter for the resources data and
     another FlatSubFormatter for the other files.
     def __init__(self, copier, omnijar_name, compress=True, non_resources=()):
         PiecemealFormatter.__init__(self, copier)
         self._omnijar_name = omnijar_name
         self._compress = compress
         self._non_resources = non_resources
         self._sub_formatter[''] = FlatSubFormatter(copier)
         jarrer = Jarrer(self._compress)
         self._sub_formatter[omnijar_name] = FlatSubFormatter(jarrer)
@@ -310,18 +316,18 @@ class OmniJarSubFormatter(PiecemealForma
             return False
         path = mozpath.split(path)
         if path[0] == 'chrome':
             return len(path) == 1 or path[1] != 'icons'
         if path[0] == 'components':
             return path[-1].endswith(('.js', '.xpt'))
         if path[0] == 'res':
             return len(path) == 1 or \
-                (path[1] != 'cursors' and \
-                 path[1] != 'touchbar' and \
+                (path[1] != 'cursors' and
+                 path[1] != 'touchbar' and
                  path[1] != 'MainMenu.nib')
         if path[0] == 'defaults':
             return len(path) != 3 or \
                 not (path[2] == 'channel-prefs.js' and
                      path[1] in ['pref', 'preferences'])
         return path[0] in [
--- a/python/mozbuild/mozpack/packager/l10n.py
+++ b/python/mozbuild/mozpack/packager/l10n.py
@@ -170,17 +170,17 @@ def _repack(app_finder, l10n_finder, cop
         if isinstance(e, ManifestEntryWithRelPath):
             base = mozpath.basedir(e.path, app.bases)
             if base not in l10n_paths:
                 errors.fatal("Locale doesn't contain %s/" % base)
                 # Allow errors to accumulate
             if key(e) not in l10n_paths[base]:
                 errors.fatal("Locale doesn't have a manifest entry for '%s'" %
-                    e.name)
+                             e.name)
                 # Allow errors to accumulate
             paths[e.path] = l10n_paths[base][key(e)]
     for pattern in non_chrome:
         for base in app.bases:
             path = mozpath.join(base, pattern)
             left = set(p for p, f in app_finder.find(path))
--- a/python/mozbuild/mozpack/packager/unpack.py
+++ b/python/mozbuild/mozpack/packager/unpack.py
@@ -35,16 +35,17 @@ class UnpackFinder(BaseFinder):
     This means that for example, paths like chrome/browser/content/... match
     files under jar:chrome/browser.jar!/content/... in case of jar chrome
     The only argument to the constructor is a Finder instance or a path.
     The UnpackFinder is populated with files from this Finder instance,
     or with files from a FileFinder using the given path as its root.
     def __init__(self, source, omnijar_name=None):
         if isinstance(source, BaseFinder):
             self._finder = source
             self._finder = FileFinder(source)
         self.base = self._finder.base
         self.files = FileRegistry()
         self.kind = 'flat'
@@ -85,17 +86,17 @@ class UnpackFinder(BaseFinder):
                 if self.files.contains(p):
                 f = m
             # If the file is a packed addon, unpack it under a directory named
             # after the xpi.
             if p.endswith('.xpi') and self._maybe_zip(f):
                 self._fill_with_jar(p[:-4], self._open_jar(p, f))
-            if not p in jars:
+            if p not in jars:
                 self.files.add(p, f)
     def _fill_with_jar(self, base, jar):
         for j in jar:
             path = mozpath.join(base, j.filename)
             if is_manifest(j.filename):
                 m = self.files[path] if self.files.contains(path) \
                     else ManifestFile(mozpath.dirname(path))
@@ -121,21 +122,21 @@ class UnpackFinder(BaseFinder):
             # haven't, try to find it now.
             if self.files.contains(jarpath):
                 jar = self.files[jarpath]
                 jar = [f for p, f in self._finder.find(jarpath)]
                 assert len(jar) == 1
                 jar = jar[0]
-            if not jarpath in jars:
+            if jarpath not in jars:
                 base = mozpath.splitext(jarpath)[0]
                 for j in self._open_jar(jarpath, jar):
-                                                     j.filename),
+                                                j.filename),
             self.kind = 'jar'
         return entry
     def _open_jar(self, path, file):
         Return a JarReader for the given BaseFile instance, keeping a log of
--- a/python/mozbuild/mozpack/test/test_copier.py
+++ b/python/mozbuild/mozpack/test/test_copier.py
@@ -114,16 +114,17 @@ class BaseTestFileRegistry(MatchTestTemp
         self.assertRaises(ErrorMessage, self.registry.add, 'bar',
         # Drop the count of things that require bar/ to 0.
         self.registry.add('bar/zot', GeneratedFile('barzot'))
 class TestFileRegistry(BaseTestFileRegistry, unittest.TestCase):
     def test_partial_paths(self):
         cases = {
             'foo/bar/baz/zot': ['foo/bar/baz', 'foo/bar', 'foo'],
             'foo/bar': ['foo'],
             'bar': [],
         reg = FileRegistry()
@@ -175,17 +176,17 @@ class TestFileRegistrySubtree(BaseTestFi
         registry.add('foo/bar', GeneratedFile('foo/bar'))
         registry.add('baz/qux', GeneratedFile('baz/qux'))
         return FileRegistrySubtree('base/root', registry)
     def test_file_registry_subtree(self):
     def test_registry_paths_subtree(self):
-        registry = FileRegistry()
+        FileRegistry()
 class TestFileCopier(TestWithTmpDir):
     def all_dirs(self, base):
         all_dirs = set()
         for root, dirs, files in os.walk(base):
             if not dirs:
@@ -210,28 +211,29 @@ class TestFileCopier(TestWithTmpDir):
         copier.add('qux/bar', GeneratedFile(''))
         result = copier.copy(self.tmpdir)
         self.assertEqual(self.all_files(self.tmpdir), set(copier.paths()))
                          set(['foo/deep/nested/directory', 'qux']))
         self.assertEqual(result.updated_files, set(self.tmppath(p) for p in
-            self.all_files(self.tmpdir)))
+                                                   self.all_files(self.tmpdir)))
         self.assertEqual(result.existing_files, set())
         self.assertEqual(result.removed_files, set())
         self.assertEqual(result.removed_directories, set())
         copier.add('test', GeneratedFile('test'))
         result = copier.copy(self.tmpdir)
         self.assertEqual(self.all_files(self.tmpdir), set(copier.paths()))
         self.assertEqual(self.all_dirs(self.tmpdir), set(['qux']))
         self.assertEqual(result.removed_files, set(self.tmppath(p) for p in
-            ('foo/bar', 'foo/qux', 'foo/deep/nested/directory/file')))
+                                                   ('foo/bar', 'foo/qux',
+                                                    'foo/deep/nested/directory/file')))
     def test_symlink_directory_replaced(self):
         """Directory symlinks in destination are replaced if they need to be
         real directories."""
         if not self.symlink_supported:
         dest = self.tmppath('dest')
@@ -276,34 +278,34 @@ class TestFileCopier(TestWithTmpDir):
         link = self.tmppath('dest/zot/zap')
         os.symlink(dummy, link)
         # If not remove_unaccounted but remove_empty_directories, then
         # the symlinked directory remains (as does its containing
         # directory).
         result = copier.copy(dest, remove_unaccounted=False,
-            remove_empty_directories=True,
-            remove_all_directory_symlinks=False)
+                             remove_empty_directories=True,
+                             remove_all_directory_symlinks=False)
         st = os.lstat(link)
         self.assertEqual(self.all_files(dest), set(copier.paths()))
         self.assertEqual(self.all_dirs(dest), set(['foo/bar']))
         self.assertEqual(result.removed_directories, set())
         self.assertEqual(len(result.updated_files), 1)
         # If remove_unaccounted but not remove_empty_directories, then
         # only the symlinked directory is removed.
         result = copier.copy(dest, remove_unaccounted=True,
-            remove_empty_directories=False,
-            remove_all_directory_symlinks=False)
+                             remove_empty_directories=False,
+                             remove_all_directory_symlinks=False)
         st = os.lstat(self.tmppath('dest/zot'))
         self.assertEqual(result.removed_files, set([link]))
         self.assertEqual(result.removed_directories, set())
@@ -311,18 +313,18 @@ class TestFileCopier(TestWithTmpDir):
         self.assertEqual(self.all_dirs(dest), set(['foo/bar', 'zot']))
         # If remove_unaccounted and remove_empty_directories, then
         # both the symlink and its containing directory are removed.
         link = self.tmppath('dest/zot/zap')
         os.symlink(dummy, link)
         result = copier.copy(dest, remove_unaccounted=True,
-            remove_empty_directories=True,
-            remove_all_directory_symlinks=False)
+                             remove_empty_directories=True,
+                             remove_all_directory_symlinks=False)
         self.assertEqual(result.removed_files, set([link]))
         self.assertEqual(result.removed_directories, set([self.tmppath('dest/zot')]))
         self.assertEqual(self.all_files(dest), set(copier.paths()))
         self.assertEqual(self.all_dirs(dest), set(['foo/bar']))
     def test_permissions(self):
@@ -358,43 +360,43 @@ class TestFileCopier(TestWithTmpDir):
         with open(self.tmppath('populateddir/foo'), 'a'):
         result = copier.copy(self.tmpdir, remove_unaccounted=False)
         self.assertEqual(self.all_files(self.tmpdir), set(['foo', 'bar',
-            'populateddir/foo']))
+                                                           'populateddir/foo']))
         self.assertEqual(self.all_dirs(self.tmpdir), set(['populateddir']))
         self.assertEqual(result.removed_files, set())
-            set([self.tmppath('emptydir')]))
+                         set([self.tmppath('emptydir')]))
     def test_no_remove_empty_directories(self):
         copier = FileCopier()
         copier.add('foo', GeneratedFile('foo'))
         with open(self.tmppath('bar'), 'a'):
         d = self.tmppath('populateddir')
         with open(self.tmppath('populateddir/foo'), 'a'):
         result = copier.copy(self.tmpdir, remove_unaccounted=False,
-            remove_empty_directories=False)
+                             remove_empty_directories=False)
         self.assertEqual(self.all_files(self.tmpdir), set(['foo', 'bar',
-            'populateddir/foo']))
+                                                           'populateddir/foo']))
         self.assertEqual(self.all_dirs(self.tmpdir), set(['emptydir',
-            'populateddir']))
+                                                          'populateddir']))
         self.assertEqual(result.removed_files, set())
         self.assertEqual(result.removed_directories, set())
     def test_optional_exists_creates_unneeded_directory(self):
         """Demonstrate that a directory not strictly required, but specified
         as the path to an optional file, will be unnecessarily created.
         This behaviour is wrong; fixing it is tracked by Bug 972432;
@@ -428,44 +430,45 @@ class TestFileCopier(TestWithTmpDir):
         copier = FileCopier()
         copier.add('foo/bar/baz', GeneratedFile('foobarbaz'))
         copier.add('foo/bar/qux', GeneratedFile('foobarqux'))
         copier.add('foo/hoge/fuga', GeneratedFile('foohogefuga'))
         copier.add('foo/toto/tata', GeneratedFile('footototata'))
         os.makedirs(os.path.join(dest, 'bar'))
         with open(os.path.join(dest, 'bar', 'bar'), 'w') as fh:
-            fh.write('barbar');
+            fh.write('barbar')
         os.makedirs(os.path.join(dest, 'foo', 'toto'))
         with open(os.path.join(dest, 'foo', 'toto', 'toto'), 'w') as fh:
-            fh.write('foototototo');
+            fh.write('foototototo')
         result = copier.copy(dest, remove_unaccounted=False)
-                         set(copier.paths()) | { 'foo/toto/toto', 'bar/bar'})
+                         set(copier.paths()) | {'foo/toto/toto', 'bar/bar'})
                          {'foo/bar', 'foo/hoge', 'foo/toto', 'bar'})
         copier2 = FileCopier()
         copier2.add('foo/hoge/fuga', GeneratedFile('foohogefuga'))
         # We expect only files copied from the first copier to be removed,
         # not the extra file that was there beforehand.
         result = copier2.copy(dest, remove_unaccounted=copier)
-                         set(copier2.paths()) | { 'foo/toto/toto', 'bar/bar'})
+                         set(copier2.paths()) | {'foo/toto/toto', 'bar/bar'})
                          {'foo/hoge', 'foo/toto', 'bar'})
         self.assertEqual(result.existing_files, set())
         self.assertEqual(result.removed_files, {self.tmppath(p) for p in
-            ('dest/foo/bar/baz', 'dest/foo/bar/qux', 'dest/foo/toto/tata')})
+                                                ('dest/foo/bar/baz', 'dest/foo/bar/qux',
+                                                 'dest/foo/toto/tata')})
 class TestJarrer(unittest.TestCase):
     def check_jar(self, dest, copier):
         jar = JarReader(fileobj=dest)
         self.assertEqual([f.filename for f in jar], copier.paths())
@@ -501,20 +504,19 @@ class TestJarrer(unittest.TestCase):
         preloaded = ['qux/bar', 'bar']
         jar = JarReader(fileobj=dest)
         self.assertEqual([f.filename for f in jar], preloaded +
-                         [p for p in copier.paths() if not p in preloaded])
+                         [p for p in copier.paths() if p not in preloaded])
         self.assertEqual(jar.last_preloaded, preloaded[-1])
     def test_jarrer_compress(self):
         copier = Jarrer()
         copier.add('foo/bar', GeneratedFile('ffffff'))
         copier.add('foo/qux', GeneratedFile('ffffff'), compress=False)
         dest = MockDest()
         self.check_jar(dest, copier)
--- a/python/mozbuild/mozpack/test/test_errors.py
+++ b/python/mozbuild/mozpack/test/test_errors.py
@@ -84,10 +84,11 @@ class TestErrorsImpl(TestErrors, unittes
                     self.assertEqual(errors.get_context(), ('foo', 1))
         self.assertEqual(self.get_output(), [
             'Error: foo:1: a',
             'Error: bar:2: b',
             'Error: foo:1: c',
 if __name__ == '__main__':
--- a/python/mozbuild/mozpack/test/test_files.py
+++ b/python/mozbuild/mozpack/test/test_files.py
@@ -96,17 +96,16 @@ class TestWithTmpDir(unittest.TestCase):
             except EnvironmentError:
             self.hardlink_supported = True
     def tearDown(self):
     def tmppath(self, relpath):
         return os.path.normpath(os.path.join(self.tmpdir, relpath))
 class MockDest(BytesIO, Dest):
@@ -154,16 +153,17 @@ class TestDest(TestWithTmpDir):
         self.assertEqual(dest.read(4), 'bar')
         self.assertEqual(dest.read(), 'bar')
         self.assertEqual(dest.read(), 'qux')
 rand = ''.join(random.choice(string.letters) for i in xrange(131597))
 samples = [
     'Different and longer',
@@ -568,23 +568,24 @@ class TestPreprocessedFile(TestWithTmpDi
         os.symlink(source, dest)
         with open(pp_source, 'wb') as tmp:
             tmp.write('#define FOO\nPREPROCESSED')
         f = PreprocessedFile(pp_source, depfile_path=deps, marker='#',
-            defines={'FOO': True})
+                             defines={'FOO': True})
         self.assertEqual('PREPROCESSED', open(dest, 'rb').read())
         self.assertEqual('', open(source, 'rb').read())
 class TestExistingFile(TestWithTmpDir):
     def test_required_missing_dest(self):
         with self.assertRaisesRegexp(ErrorMessage, 'Required existing file'):
             f = ExistingFile(required=True)
     def test_required_existing_dest(self):
         p = self.tmppath('dest')
@@ -687,16 +688,17 @@ class TestGeneratedFile(TestWithTmpDir):
         self.assertEqual('modified', f.read())
         self.assertEqual(len('modified'), f.size())
         f.content = content
         self.assertEqual(data['num_calls'], 1)
         self.assertEqual('content', f.read())
         self.assertEqual(data['num_calls'], 2)
 class TestDeflatedFile(TestWithTmpDir):
     def test_deflated_file(self):
         Check that DeflatedFile.copy yields the proper content in the
         destination file in all situations that trigger different code paths
         (see TestFile.test_file)
         src = self.tmppath('src.jar')
@@ -802,16 +804,17 @@ class TestManifestFile(TestWithTmpDir):
             ManifestContent('chrome', 'global', 'toolkit/content/global/')
         content = open(self.tmppath('chrome.manifest')).read()
         self.assertEqual(content[:42], f.open().read(42))
         self.assertEqual(content, f.open().read())
 # Compiled typelib for the following IDL:
 #     interface foo;
 #     [scriptable, uuid(5f70da76-519c-4858-b71e-e3c92333e2d6)]
 #     interface bar {
 #         void bar(in foo f);
 #     };
 # We need to make this [scriptable] so it doesn't get deleted from the
 # typelib.  We don't need to make the foo interfaces below [scriptable],
@@ -898,34 +901,34 @@ class TestMinifiedJavaScript(TestWithTmp
             os.path.join(our_dir, 'support', 'minify_js_verify.py'),
     def test_minified_verify_success(self):
         orig_f = GeneratedFile('\n'.join(self.orig_lines))
         min_f = MinifiedJavaScript(orig_f,
-            verify_command=self._verify_command('0'))
+                                   verify_command=self._verify_command('0'))
         mini_lines = min_f.open().readlines()
         self.assertTrue(len(mini_lines) < len(self.orig_lines))
     def test_minified_verify_failure(self):
         orig_f = GeneratedFile('\n'.join(self.orig_lines))
         errors.out = StringIO()
         min_f = MinifiedJavaScript(orig_f,
-            verify_command=self._verify_command('1'))
+                                   verify_command=self._verify_command('1'))
         mini_lines = min_f.open().readlines()
         output = errors.out.getvalue()
         errors.out = sys.stderr
-            'Warning: JS minification verification failed for <unknown>:\n'
-            'Warning: Error message\n')
+                         'Warning: JS minification verification failed for <unknown>:\n'
+                         'Warning: Error message\n')
         self.assertEqual(mini_lines, orig_f.open().readlines())
 class MatchTestTemplate(object):
     def prepare_match_test(self, with_dotfiles=False):
@@ -1055,44 +1058,44 @@ class TestFileFinder(MatchTestTemplate, 
         """Ignored files should not have results returned."""
         # Be sure prefix match doesn't get ignored.
         self.finder = FileFinder(self.tmpdir, ignore=['foo/bar', 'bar'])
         self.do_check('**', ['barz', 'foo/baz', 'foo/qux/1', 'foo/qux/2/test',
-            'foo/qux/2/test2', 'foo/qux/bar'])
+                             'foo/qux/2/test2', 'foo/qux/bar'])
         self.do_check('foo/**', ['foo/baz', 'foo/qux/1', 'foo/qux/2/test',
-            'foo/qux/2/test2', 'foo/qux/bar'])
+                                 'foo/qux/2/test2', 'foo/qux/bar'])
     def test_ignored_patterns(self):
         """Ignore entries with patterns should be honored."""
         self.finder = FileFinder(self.tmpdir, ignore=['foo/qux/*'])
         self.do_check('**', ['foo/bar', 'foo/baz', 'foo/quxz', 'bar'])
         self.do_check('foo/**', ['foo/bar', 'foo/baz', 'foo/quxz'])
     def test_dotfiles(self):
         """Finder can find files beginning with . is configured."""
         self.finder = FileFinder(self.tmpdir, find_dotfiles=True)
         self.do_check('**', ['bar', 'foo/.foo', 'foo/.bar/foo',
-            'foo/bar', 'foo/baz', 'foo/qux/1', 'foo/qux/bar',
-            'foo/qux/2/test', 'foo/qux/2/test2'])
+                             'foo/bar', 'foo/baz', 'foo/qux/1', 'foo/qux/bar',
+                             'foo/qux/2/test', 'foo/qux/2/test2'])
     def test_dotfiles_plus_ignore(self):
         self.finder = FileFinder(self.tmpdir, find_dotfiles=True,
         self.do_check('foo/**', ['foo/.foo', 'foo/bar', 'foo/baz',
-            'foo/qux/1', 'foo/qux/bar', 'foo/qux/2/test', 'foo/qux/2/test2'])
+                                 'foo/qux/1', 'foo/qux/bar', 'foo/qux/2/test', 'foo/qux/2/test2'])
 class TestJarFinder(MatchTestTemplate, TestWithTmpDir):
     def add(self, path):
         self.jar.add(path, path, compress=True)
     def do_check(self, pattern, result):
         do_check(self, self.finder, pattern, result)
@@ -1103,16 +1106,17 @@ class TestJarFinder(MatchTestTemplate, T
         reader = JarReader(file=self.tmppath('test.jar'))
         self.finder = JarFinder(self.tmppath('test.jar'), reader)
         self.assertIsInstance(self.finder.get('bar'), DeflatedFile)
 class TestTarFinder(MatchTestTemplate, TestWithTmpDir):
     def add(self, path):
     def do_check(self, pattern, result):
         do_check(self, self.finder, pattern, result)
     def test_tar_finder(self):
--- a/python/mozbuild/mozpack/test/test_manifests.py
+++ b/python/mozbuild/mozpack/test/test_manifests.py
@@ -23,17 +23,17 @@ class TestInstallManifest(TestWithTmpDir
     def test_construct(self):
         m = InstallManifest()
         self.assertEqual(len(m), 0)
     def test_malformed(self):
         f = self.tmppath('manifest')
         open(f, 'wb').write('junk\n')
         with self.assertRaises(UnreadableInstallManifest):
-            m = InstallManifest(f)
+            InstallManifest(f)
     def test_adds(self):
         m = InstallManifest()
         m.add_link('s_source', 's_dest')
         m.add_copy('c_source', 'c_dest')
         m.add_pattern_link('ps_base', 'ps/*', 'ps_dest')
@@ -72,17 +72,18 @@ class TestInstallManifest(TestWithTmpDir
         with self.assertRaises(ValueError):
             m.add_content('content', 'content')
     def _get_test_manifest(self):
         m = InstallManifest()
         m.add_link(self.tmppath('s_source'), 's_dest')
         m.add_copy(self.tmppath('c_source'), 'c_dest')
-        m.add_preprocess(self.tmppath('p_source'), 'p_dest', self.tmppath('p_source.pp'), '#', {'FOO':'BAR', 'BAZ':'QUX'})
+        m.add_preprocess(self.tmppath('p_source'), 'p_dest', self.tmppath(
+            'p_source.pp'), '#', {'FOO': 'BAR', 'BAZ': 'QUX'})
         m.add_pattern_link('ps_base', '*', 'ps_dest')
         m.add_pattern_copy('pc_base', '**', 'pc_dest')
         m.add_content('the content\non\nmultiple lines', 'content')
         return m
@@ -221,17 +222,17 @@ class TestInstallManifest(TestWithTmpDir
             self.assertEqual(fh.read(), 'copy!')
         with open(self.tmppath('dest/p_dest'), 'rt') as fh:
             self.assertEqual(fh.read(), 'preprocess!')
         self.assertEqual(result.updated_files, set(self.tmppath(p) for p in (
             'dest/s_dest', 'dest/c_dest', 'dest/p_dest', 'dest/content')))
-            set([self.tmppath('dest/e_dest'), self.tmppath('dest/o_dest')]))
+                         set([self.tmppath('dest/e_dest'), self.tmppath('dest/o_dest')]))
         self.assertEqual(result.removed_files, {to_delete})
         self.assertEqual(result.removed_directories, set())
     def test_preprocessor(self):
         manifest = self.tmppath('m')
         deps = self.tmppath('m.pp')
         dest = self.tmppath('dest')
         include = self.tmppath('p_incl')
@@ -246,34 +247,35 @@ class TestInstallManifest(TestWithTmpDir
             fh.write('#ifdef DEPTEST\nPASS2\n#endif\n')
             fh.write('#include p_incl\n#ifdef INCLTEST\nPASS3\n#endif\n')
         time = os.path.getmtime(self.tmppath('p_source')) - 3
         os.utime(self.tmppath('p_source'), (time, time))
         # Create and write a manifest with the preprocessed file, then apply it.
         # This should write out our preprocessed file.
         m = InstallManifest()
-        m.add_preprocess(self.tmppath('p_source'), 'p_dest', deps, '#', {'FOO':'BAR', 'BAZ':'QUX'})
+        m.add_preprocess(self.tmppath('p_source'), 'p_dest',
+                         deps, '#', {'FOO': 'BAR', 'BAZ': 'QUX'})
         m = InstallManifest(path=manifest)
         c = FileCopier()
         with open(self.tmppath('dest/p_dest'), 'rt') as fh:
             self.assertEqual(fh.read(), 'PASS1\n')
         # Create a second manifest with the preprocessed file, then apply it.
         # Since this manifest does not exist on the disk, there should not be a
         # dependency on it, and the preprocessed file should not be modified.
         m2 = InstallManifest()
-        m2.add_preprocess(self.tmppath('p_source'), 'p_dest', deps, '#', {'DEPTEST':True})
+        m2.add_preprocess(self.tmppath('p_source'), 'p_dest', deps, '#', {'DEPTEST': True})
         c = FileCopier()
         result = c.copy(dest)
         self.assertFalse(self.tmppath('dest/p_dest') in result.updated_files)
         self.assertTrue(self.tmppath('dest/p_dest') in result.existing_files)
         # Write out the second manifest, then load it back in from the disk.
@@ -327,17 +329,17 @@ class TestInstallManifest(TestWithTmpDir
         with open(include, 'wt') as fh:
         time = os.path.getmtime(source) - 3
         os.utime(include, (time, time))
         # Create and write a manifest with the preprocessed file.
         m = InstallManifest()
-        m.add_preprocess(source, 'p_dest', deps, '#', {'FOO':'BAR', 'BAZ':'QUX'})
+        m.add_preprocess(source, 'p_dest', deps, '#', {'FOO': 'BAR', 'BAZ': 'QUX'})
         time = os.path.getmtime(source) - 5
         os.utime(manifest, (time, time))
         # Now read the manifest back in, and apply it. This should write out
         # our preprocessed file.
         m = InstallManifest(path=manifest)
--- a/python/mozbuild/mozpack/test/test_mozjar.py
+++ b/python/mozbuild/mozpack/test/test_mozjar.py
@@ -159,20 +159,20 @@ class TestJar(unittest.TestCase):
         self.assertEqual(files[1].read(), 'aaaaaaaaaaaaanopqrstuvwxyz')
         self.assertEqual(files[2].filename, 'baz/qux')
         self.assertEqual(files[2].read(), 'aaaaaaaaaaaaanopqrstuvwxyz')
         if os.sep == '\\':
             self.assertEqual(files[3].filename, 'baz/backslash',
-                'backslashes in filenames on Windows should get normalized')
+                             'backslashes in filenames on Windows should get normalized')
             self.assertEqual(files[3].filename, 'baz\\backslash',
-                'backslashes in filenames on POSIX platform are untouched')
+                             'backslashes in filenames on POSIX platform are untouched')
         s = MockDest()
         with JarWriter(fileobj=s, compress=False) as jar:
             jar.add('bar', 'aaaaaaaaaaaaanopqrstuvwxyz')
             jar.add('foo', 'foo')
             jar.add('baz/qux', 'aaaaaaaaaaaaanopqrstuvwxyz', True)
         jar = JarReader(fileobj=s)
@@ -302,18 +302,20 @@ class TestJarLog(unittest.TestCase):
             'jar:' + base + '/qux.zip!/omni.ja other/stuff',
             'jar:' + base + '/qux.zip!/omni.ja stuff',
             base + '/bar/baz.jar third',
             'jar:jar:' + base + '/qux.zip!/baz/baz.jar!/omni.ja nested/stuff',
             'jar:jar:jar:' + base + '/qux.zip!/baz/baz.jar!/foo.zip!/omni.ja' +
             ' deeply/nested/stuff',
         log = JarLog(fileobj=s)
-        canonicalize = lambda p: \
-            mozpath.normsep(os.path.normcase(os.path.realpath(p)))
+        def canonicalize(p):
+            return mozpath.normsep(os.path.normcase(os.path.realpath(p)))
         baz_jar = canonicalize('bar/baz.jar')
         qux_zip = canonicalize('qux.zip')
         self.assertEqual(set(log.keys()), set([
             (qux_zip, 'omni.ja'),
             (qux_zip, 'baz/baz.jar', 'omni.ja'),
             (qux_zip, 'baz/baz.jar', 'foo.zip', 'omni.ja'),
--- a/python/mozbuild/mozpack/test/test_packager.py
+++ b/python/mozbuild/mozpack/test/test_packager.py
@@ -238,17 +238,18 @@ class TestSimplePackager(unittest.TestCa
                 '<RDF>\n<... em:unpack=\'true\'>\n<...>\n</RDF>')
             packager.add('addon10/install.rdf', install_rdf_addon10)
         with errors.context('manifest', 19):
             install_rdf_addon11 = GeneratedFile(
                 '<RDF>\n<... em:unpack=\'false\'>\n<...>\n</RDF>')
             packager.add('addon11/install.rdf', install_rdf_addon11)
-        we_manifest = GeneratedFile('{"manifest_version": 2, "name": "Test WebExtension", "version": "1.0"}')
+        we_manifest = GeneratedFile(
+            '{"manifest_version": 2, "name": "Test WebExtension", "version": "1.0"}')
         # hybrid and hybrid2 are both bootstrapped extensions with
         # embedded webextensions, they differ in the order in which
         # the manifests are added to the packager.
         with errors.context('manifest', 20):
             packager.add('hybrid/install.rdf', install_rdf)
         with errors.context('manifest', 21):
             packager.add('hybrid/webextension/manifest.json', we_manifest)
@@ -360,18 +361,18 @@ class TestSimplePackager(unittest.TestCa
         packager.add('foo/bar.manifest', GeneratedFile('resource bar bar'))
         packager.add('bar/baz.manifest', GeneratedFile('resource baz baz'))
         packager.add('bar/install.rdf', GeneratedFile(''))
         with self.assertRaises(ErrorMessage) as e:
-            'Error: "bar/baz.manifest" is included from "base.manifest", '
-            'which is outside "bar"')
+                         'Error: "bar/baz.manifest" is included from "base.manifest", '
+                         'which is outside "bar"')
         # bar/ is detected as a separate base because of chrome.manifest that
         # is included nowhere, but top-level includes another manifest inside
         # bar/.
         packager = SimplePackager(formatter)
         packager.add('base.manifest', GeneratedFile(
             'manifest foo/bar.manifest\n'
             'manifest bar/baz.manifest\n'
@@ -379,18 +380,18 @@ class TestSimplePackager(unittest.TestCa
         packager.add('foo/bar.manifest', GeneratedFile('resource bar bar'))
         packager.add('bar/baz.manifest', GeneratedFile('resource baz baz'))
         packager.add('bar/chrome.manifest', GeneratedFile('resource baz baz'))
         with self.assertRaises(ErrorMessage) as e:
-            'Error: "bar/baz.manifest" is included from "base.manifest", '
-            'which is outside "bar"')
+                         'Error: "bar/baz.manifest" is included from "base.manifest", '
+                         'which is outside "bar"')
         # bar/ is detected as a separate base because of chrome.manifest that
         # is included nowhere, but chrome.manifest includes baz.manifest from
         # the same directory. This shouldn't error out.
         packager = SimplePackager(formatter)
         packager.add('base.manifest', GeneratedFile(
             'manifest foo/bar.manifest\n'
@@ -482,23 +483,23 @@ class TestComponent(unittest.TestCase):
         self.assertEqual(name, n)
         self.assertEqual(options, o)
     def test_component_split_component_and_options(self):
         self.do_split('component', 'component', {})
         self.do_split('trailingspace ', 'trailingspace', {})
         self.do_split(' leadingspace', 'leadingspace', {})
         self.do_split(' trim ', 'trim', {})
-        self.do_split(' trim key="value"', 'trim', {'key':'value'})
-        self.do_split(' trim empty=""', 'trim', {'empty':''})
-        self.do_split(' trim space=" "', 'trim', {'space':' '})
+        self.do_split(' trim key="value"', 'trim', {'key': 'value'})
+        self.do_split(' trim empty=""', 'trim', {'empty': ''})
+        self.do_split(' trim space=" "', 'trim', {'space': ' '})
         self.do_split('component key="value"  key2="second" ',
-                      'component', {'key':'value', 'key2':'second'})
-        self.do_split( 'trim key="  value with spaces   "  key2="spaces again"',
-                       'trim', {'key':'  value with spaces   ', 'key2': 'spaces again'})
+                      'component', {'key': 'value', 'key2': 'second'})
+        self.do_split('trim key="  value with spaces   "  key2="spaces again"',
+                      'trim', {'key': '  value with spaces   ', 'key2': 'spaces again'})
     def do_split_error(self, string):
         self.assertRaises(ValueError, Component._split_component_and_options, string)
     def test_component_split_component_and_options_errors(self):
--- a/python/mozbuild/mozpack/test/test_packager_formats.py
+++ b/python/mozbuild/mozpack/test/test_packager_formats.py
@@ -18,17 +18,16 @@ from mozpack.chrome.manifest import (
 from mozpack.errors import (
-    errors,
 from mozpack.test.test_files import (
 import mozpack.path as mozpath
@@ -259,24 +258,26 @@ CONTENTS_WITH_BASE = {
     'extra/file': GeneratedFile('extra file'),
 def result_with_base(results):
     result = {
         mozpath.join('base/root', p): v
         for p, v in results.iteritems()
     return result
 RESULT_JAR_WITH_BASE = result_with_base(RESULT_JAR)
 def fill_formatter(formatter, contents):
     for base, is_addon in contents['bases'].items():
         formatter.add_base(base, is_addon)
@@ -442,69 +443,69 @@ class TestFormatters(TestErrors, unittes
         f.add_manifest(ManifestContent('chrome', 'foo', 'foo/win', 'os=WINNT'))
         f.add_manifest(ManifestContent('chrome', 'foo', 'foo/osx', 'os=Darwin'))
         # Chrome with the same name overrides the previous registration.
         with self.assertRaises(ErrorMessage) as e:
             f.add_manifest(ManifestContent('chrome', 'foo', 'foo/'))
-            'Error: "content foo foo/" overrides '
-            '"content foo foo/unix"')
+                         'Error: "content foo foo/" overrides '
+                         '"content foo foo/unix"')
         # Chrome with the same name and same flags overrides the previous
         # registration.
         with self.assertRaises(ErrorMessage) as e:
             f.add_manifest(ManifestContent('chrome', 'foo', 'foo/', 'os=WINNT'))
-            'Error: "content foo foo/ os=WINNT" overrides '
-            '"content foo foo/win os=WINNT"')
+                         'Error: "content foo foo/ os=WINNT" overrides '
+                         '"content foo foo/win os=WINNT"')
         # We may start with the more specific entry first
         f.add_manifest(ManifestContent('chrome', 'bar', 'bar/win', 'os=WINNT'))
         # Then adding a more generic one overrides it.
         with self.assertRaises(ErrorMessage) as e:
             f.add_manifest(ManifestContent('chrome', 'bar', 'bar/unix'))
-            'Error: "content bar bar/unix" overrides '
-            '"content bar bar/win os=WINNT"')
+                         'Error: "content bar bar/unix" overrides '
+                         '"content bar bar/win os=WINNT"')
         # Adding something more specific still works.
         f.add_manifest(ManifestContent('chrome', 'bar', 'bar/win',
                                        'os=WINNT osversion>=7.0'))
         # Variations of skin/locales are allowed.
         f.add_manifest(ManifestSkin('chrome', 'foo', 'classic/1.0',
         f.add_manifest(ManifestSkin('chrome', 'foo', 'modern/1.0',
         f.add_manifest(ManifestLocale('chrome', 'foo', 'en-US',
-                                    'foo/locale/en-US/'))
+                                      'foo/locale/en-US/'))
         f.add_manifest(ManifestLocale('chrome', 'foo', 'ja-JP',
-                                    'foo/locale/ja-JP/'))
+                                      'foo/locale/ja-JP/'))
         # But same-skin/locale still error out.
         with self.assertRaises(ErrorMessage) as e:
             f.add_manifest(ManifestSkin('chrome', 'foo', 'classic/1.0',
-            'Error: "skin foo classic/1.0 foo/skin/classic/foo" overrides '
-            '"skin foo classic/1.0 foo/skin/classic/"')
+                         'Error: "skin foo classic/1.0 foo/skin/classic/foo" overrides '
+                         '"skin foo classic/1.0 foo/skin/classic/"')
         with self.assertRaises(ErrorMessage) as e:
             f.add_manifest(ManifestLocale('chrome', 'foo', 'en-US',
-                                         'foo/locale/en-US/foo'))
+                                          'foo/locale/en-US/foo'))
-            'Error: "locale foo en-US foo/locale/en-US/foo" overrides '
-            '"locale foo en-US foo/locale/en-US/"')
+                         'Error: "locale foo en-US foo/locale/en-US/foo" overrides '
+                         '"locale foo en-US foo/locale/en-US/"')
         # Duplicating existing manifest entries is not an error.
         f.add_manifest(ManifestContent('chrome', 'foo', 'foo/unix'))
         self.assertEqual(self.get_output(), [
             'Warning: "content foo foo/unix" is duplicated. Skipping.',
--- a/python/mozbuild/mozpack/test/test_packager_unpack.py
+++ b/python/mozbuild/mozpack/test/test_packager_unpack.py
@@ -53,16 +53,17 @@ class TestUnpack(TestWithTmpDir):
     def test_jar_unpack(self):
     def _omni_foo_formatter(name):
         class OmniFooFormatter(OmniJarFormatter):
             OMNIJAR_NAME = name
             def __init__(self, registry):
                 super(OmniFooFormatter, self).__init__(registry, name)
         return OmniFooFormatter
     def test_omnijar_unpack(self):
     def test_omnijar_subpath_unpack(self):