[diffoscope] 01/07: Tidy imports.

Chris Lamb chris at chris-lamb.co.uk
Mon Aug 15 21:55:54 CEST 2016


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit 5d73cf31d6d4aebeded614a2d80178ce48cde055
Author: Chris Lamb <lamby at debian.org>
Date:   Mon Aug 15 19:44:40 2016 +0100

    Tidy imports.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 bin/diffoscope                            |  3 +-
 diffoscope/__init__.py                    | 13 ++---
 diffoscope/changes.py                     |  2 +
 diffoscope/comparators/__init__.py        | 89 +++++++++++++++++--------------
 diffoscope/comparators/ar.py              |  9 ++--
 diffoscope/comparators/binary.py          | 37 +++++++------
 diffoscope/comparators/bzip2.py           | 11 ++--
 diffoscope/comparators/cbfs.py            |  8 +--
 diffoscope/comparators/cpio.py            |  5 +-
 diffoscope/comparators/deb.py             | 18 ++++---
 diffoscope/comparators/debian.py          | 20 +++----
 diffoscope/comparators/debian_fallback.py |  2 +
 diffoscope/comparators/device.py          |  7 +--
 diffoscope/comparators/dex.py             |  5 +-
 diffoscope/comparators/directory.py       |  7 +--
 diffoscope/comparators/elf.py             | 17 +++---
 diffoscope/comparators/fonts.py           |  5 +-
 diffoscope/comparators/fsimage.py         | 14 ++---
 diffoscope/comparators/gettext.py         | 11 ++--
 diffoscope/comparators/gzip.py            |  9 ++--
 diffoscope/comparators/haskell.py         | 10 ++--
 diffoscope/comparators/icc.py             |  5 +-
 diffoscope/comparators/ipk.py             |  1 +
 diffoscope/comparators/iso9660.py         |  5 +-
 diffoscope/comparators/java.py            |  7 +--
 diffoscope/comparators/libarchive.py      |  9 ++--
 diffoscope/comparators/llvm.py            |  4 +-
 diffoscope/comparators/macho.py           |  5 +-
 diffoscope/comparators/mono.py            |  5 +-
 diffoscope/comparators/pdf.py             |  5 +-
 diffoscope/comparators/png.py             |  9 ++--
 diffoscope/comparators/ppu.py             |  5 +-
 diffoscope/comparators/ps.py              |  3 +-
 diffoscope/comparators/rpm.py             | 16 +++---
 diffoscope/comparators/rpm_fallback.py    |  2 +
 diffoscope/comparators/rust.py            | 11 ++--
 diffoscope/comparators/sqlite.py          |  2 +-
 diffoscope/comparators/squashfs.py        | 13 ++---
 diffoscope/comparators/symlink.py         |  5 +-
 diffoscope/comparators/tar.py             |  4 +-
 diffoscope/comparators/text.py            |  5 +-
 diffoscope/comparators/utils.py           | 55 +++++++++----------
 diffoscope/comparators/xz.py              | 11 ++--
 diffoscope/comparators/zip.py             | 13 ++---
 diffoscope/difference.py                  | 21 ++++----
 diffoscope/main.py                        | 28 +++++-----
 diffoscope/presenters/html.py             | 16 +++---
 diffoscope/presenters/text.py             |  1 +
 setup.py                                  |  3 +-
 tests/comparators/conftest.py             |  8 +--
 tests/comparators/test_binary.py          | 11 ++--
 tests/comparators/test_bzip2.py           |  5 +-
 tests/comparators/test_cbfs.py            | 18 ++++---
 tests/comparators/test_cpio.py            |  8 +--
 tests/comparators/test_deb.py             |  9 ++--
 tests/comparators/test_debian.py          | 11 ++--
 tests/comparators/test_dex.py             |  8 +--
 tests/comparators/test_directory.py       |  4 +-
 tests/comparators/test_elf.py             | 17 +++---
 tests/comparators/test_epub.py            |  8 +--
 tests/comparators/test_fonts.py           |  8 +--
 tests/comparators/test_fsimage.py         | 15 +++---
 tests/comparators/test_gettext.py         |  6 ++-
 tests/comparators/test_gzip.py            |  5 +-
 tests/comparators/test_icc.py             |  8 +--
 tests/comparators/test_image.py           |  7 +--
 tests/comparators/test_ipk.py             |  7 +--
 tests/comparators/test_iso9660.py         |  6 ++-
 tests/comparators/test_java.py            |  8 +--
 tests/comparators/test_macho.py           |  8 +--
 tests/comparators/test_mono.py            |  8 +--
 tests/comparators/test_pdf.py             |  8 +--
 tests/comparators/test_png.py             |  8 +--
 tests/comparators/test_ppu.py             |  8 +--
 tests/comparators/test_ps.py              |  6 ++-
 tests/comparators/test_rlib.py            | 11 ++--
 tests/comparators/test_rpm.py             |  9 ++--
 tests/comparators/test_sqlite.py          |  6 ++-
 tests/comparators/test_squashfs.py        |  6 ++-
 tests/comparators/test_tar.py             |  7 +--
 tests/comparators/test_text.py            |  5 +-
 tests/comparators/test_utils.py           | 20 ++++---
 tests/comparators/test_xz.py              |  8 +--
 tests/comparators/test_zip.py             |  6 ++-
 tests/test_difference.py                  | 16 +++---
 tests/test_main.py                        |  4 +-
 86 files changed, 512 insertions(+), 380 deletions(-)

diff --git a/bin/diffoscope b/bin/diffoscope
index 5acdfdf..2ad123b 100755
--- a/bin/diffoscope
+++ b/bin/diffoscope
@@ -19,8 +19,9 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
+import os
 import sys
+
 for root in ['.', '..']:
     if os.path.exists(os.path.join(root, 'diffoscope/__init__.py')):
         sys.path = [root] + sys.path
diff --git a/diffoscope/__init__.py b/diffoscope/__init__.py
index 7dae994..9837445 100644
--- a/diffoscope/__init__.py
+++ b/diffoscope/__init__.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from functools import wraps
-import logging
-from distutils.spawn import find_executable
 import os
 import shutil
+import logging
+import platform
 import tempfile
+import functools
+
+from distutils.spawn import find_executable
 
 VERSION = "59"
 
@@ -231,7 +233,6 @@ class OutputParsingError(Exception):
         self.object_class = object.__class__
 
 def get_current_os():
-    import platform
     system = platform.system()
     if system == "Linux":
         # FIXME: Will break under Python 3.7, see:
@@ -247,11 +248,11 @@ def tool_required(command):
     tool_required.all.add(command)
     def wrapper(original_function):
         if find_executable(command):
-            @wraps(original_function)
+            @functools.wraps(original_function)
             def tool_check(*args, **kwargs):
                 return original_function(*args, **kwargs)
         else:
-            @wraps(original_function)
+            @functools.wraps(original_function)
             def tool_check(*args, **kwargs):
                 raise RequiredToolNotFound(command)
         return tool_check
diff --git a/diffoscope/changes.py b/diffoscope/changes.py
index 6a77f6e..7e03b4d 100644
--- a/diffoscope/changes.py
+++ b/diffoscope/changes.py
@@ -44,7 +44,9 @@ __license__ = 'MIT'
 import os.path
 import hashlib
 import subprocess
+
 from debian import deb822
+
 from diffoscope import logger, tool_required
 
 
diff --git a/diffoscope/comparators/__init__.py b/diffoscope/comparators/__init__.py
index 53e3423..f2a6939 100644
--- a/diffoscope/comparators/__init__.py
+++ b/diffoscope/comparators/__init__.py
@@ -18,68 +18,75 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
+import re
+import sys
 import magic
 import operator
 import os.path
-import re
-import sys
-try:
-    import tlsh
-except ImportError:
-    tlsh = None
+
 from diffoscope import logger, tool_required
 from diffoscope.config import Config
 from diffoscope.difference import Difference
 from diffoscope.comparators.ar import ArFile
-from diffoscope.comparators.binary import \
-    File, FilesystemFile, NonExistingFile, compare_binary_files
-from diffoscope.comparators.bzip2 import Bzip2File
-from diffoscope.comparators.java import ClassFile
-from diffoscope.comparators.cbfs import CbfsFile
-from diffoscope.comparators.cpio import CpioFile
+from diffoscope.comparators.ps import PsFile
+from diffoscope.comparators.xz import XzFile
 from diffoscope.comparators.deb import DebFile, Md5sumsFile, DebDataTarFile
-try:
-    from diffoscope.comparators.debian import DotChangesFile, DotDscFile, DotBuildinfoFile
-except ImportError as ex:
-    if hasattr(ex, 'msg') and not ex.msg.startswith("No module named 'debian"):
-        raise
-    from diffoscope.comparators.debian_fallback import DotChangesFile, DotDscFile, DotBuildinfoFile
-from diffoscope.comparators.device import Device
+from diffoscope.comparators.zip import ZipFile, MozillaZipFile
 from diffoscope.comparators.dex import DexFile
-from diffoscope.comparators.directory import FilesystemDirectory, Directory, compare_directories
+from diffoscope.comparators.tar import TarFile
+from diffoscope.comparators.ipk import IpkFile
+from diffoscope.comparators.png import PngFile
+from diffoscope.comparators.ppu import PpuFile
 from diffoscope.comparators.elf import ElfFile, ElfSection, StaticLibFile
-from diffoscope.comparators.fsimage import FsImageFile
-from diffoscope.comparators.fonts import TtfFile
-from diffoscope.comparators.gettext import MoFile
+from diffoscope.comparators.icc import IccFile
 from diffoscope.comparators.git import GitIndexFile
+from diffoscope.comparators.pdf import PdfFile
+from diffoscope.comparators.rust import RustObjectFile
+from diffoscope.comparators.cpio import CpioFile
+from diffoscope.comparators.text import TextFile
 from diffoscope.comparators.gzip import GzipFile
-from diffoscope.comparators.haskell import HiFile
-from diffoscope.comparators.icc import IccFile
-from diffoscope.comparators.image import ImageFile
-from diffoscope.comparators.ipk import IpkFile
-from diffoscope.comparators.iso9660 import Iso9660File
+from diffoscope.comparators.java import ClassFile
 from diffoscope.comparators.json import JSONFile
 from diffoscope.comparators.llvm import LlvmBitCodeFile
-from diffoscope.comparators.macho import MachoFile
 from diffoscope.comparators.mono import MonoExeFile
-from diffoscope.comparators.pdf import PdfFile
-from diffoscope.comparators.png import PngFile
-from diffoscope.comparators.ppu import PpuFile
-from diffoscope.comparators.ps import PsFile
-from diffoscope.comparators.rust import RustObjectFile
+from diffoscope.comparators.cbfs import CbfsFile
+from diffoscope.comparators.image import ImageFile
+from diffoscope.comparators.fonts import TtfFile
+from diffoscope.comparators.macho import MachoFile
+from diffoscope.comparators.bzip2 import Bzip2File
+from diffoscope.comparators.sqlite import Sqlite3Database
+from diffoscope.comparators.binary import File, FilesystemFile, NonExistingFile, \
+    compare_binary_files
+from diffoscope.comparators.device import Device
+from diffoscope.comparators.symlink import Symlink
+from diffoscope.comparators.fsimage import FsImageFile
+from diffoscope.comparators.gettext import MoFile
+from diffoscope.comparators.iso9660 import Iso9660File
+from diffoscope.comparators.haskell import HiFile
+from diffoscope.comparators.squashfs import SquashfsFile
+from diffoscope.comparators.directory import FilesystemDirectory, Directory, \
+    compare_directories
+
+try:
+    import tlsh
+except ImportError:
+    tlsh = None
+
+try:
+    from diffoscope.comparators.debian import DotChangesFile, DotDscFile, \
+        DotBuildinfoFile
+except ImportError as ex:
+    if hasattr(ex, 'msg') and not ex.msg.startswith("No module named 'debian"):
+        raise
+    from diffoscope.comparators.debian_fallback import DotChangesFile, \
+        DotDscFile, DotBuildinfoFile
+
 try:
     from diffoscope.comparators.rpm import RpmFile
 except ImportError as ex:
     if hasattr(ex, 'msg') and ex.msg != "No module named 'rpm'":
         raise
     from diffoscope.comparators.rpm_fallback import RpmFile
-from diffoscope.comparators.sqlite import Sqlite3Database
-from diffoscope.comparators.squashfs import SquashfsFile
-from diffoscope.comparators.symlink import Symlink
-from diffoscope.comparators.text import TextFile
-from diffoscope.comparators.tar import TarFile
-from diffoscope.comparators.xz import XzFile
-from diffoscope.comparators.zip import ZipFile, MozillaZipFile
 
 
 def bail_if_non_existing(*paths):
diff --git a/diffoscope/comparators/ar.py b/diffoscope/comparators/ar.py
index cc54aec..0a82ade 100644
--- a/diffoscope/comparators/ar.py
+++ b/diffoscope/comparators/ar.py
@@ -19,12 +19,13 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
-from diffoscope import tool_required
+
+from diffoscope import logger, tool_required
 from diffoscope.difference import Difference
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.libarchive import LibarchiveContainer, list_libarchive
 from diffoscope.comparators.utils import Command
-from diffoscope import logger
+from diffoscope.comparators.binary import File
+from diffoscope.comparators.libarchive import LibarchiveContainer, \
+    list_libarchive
 
 
 # TODO: this would also be useful for Go archives. Currently those are handled
diff --git a/diffoscope/comparators/binary.py b/diffoscope/comparators/binary.py
index c6bdb5b..6a9a8e1 100644
--- a/diffoscope/comparators/binary.py
+++ b/diffoscope/comparators/binary.py
@@ -17,22 +17,25 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from abc import ABCMeta, abstractmethod
-from binascii import hexlify
-from io import StringIO
+import io
 import os
-import os.path
 import re
-from stat import S_ISCHR, S_ISBLK
+import abc
+import stat
+import magic
+import binascii
 import subprocess
+
+from diffoscope import tool_required, RequiredToolNotFound, logger, \
+    OutputParsingError
+from diffoscope.config import Config
+from diffoscope.difference import Difference
+
 try:
     import tlsh
 except ImportError:
     tlsh = None
-import magic
-from diffoscope.config import Config
-from diffoscope.difference import Difference
-from diffoscope import tool_required, RequiredToolNotFound, OutputParsingError, logger
+
 
 # helper function to convert to bytes if necessary
 def maybe_decode(s):
@@ -42,10 +45,10 @@ def maybe_decode(s):
         return s
 
 def hexdump_fallback(path):
-    hexdump = StringIO()
+    hexdump = io.StringIO()
     with open(path, 'rb') as f:
         for buf in iter(lambda: f.read(32), b''):
-            hexdump.write('%s\n' % hexlify(buf).decode('us-ascii'))
+            hexdump.write('%s\n' % binascii.hexlify(buf).decode('us-ascii'))
     return hexdump.getvalue()
 
 
@@ -62,7 +65,7 @@ def compare_binary_files(file1, file2, source=None):
 SMALL_FILE_THRESHOLD = 65536 # 64 kiB
 
 
-class File(object, metaclass=ABCMeta):
+class File(object, metaclass=abc.ABCMeta):
     if hasattr(magic, 'open'): # use Magic-file-extensions from file
         @classmethod
         def guess_file_type(self, path):
@@ -98,7 +101,7 @@ class File(object, metaclass=ABCMeta):
 
     # This should return a path that allows to access the file content
     @property
-    @abstractmethod
+    @abc.abstractmethod
     def path(self):
         raise NotImplementedError()
 
@@ -154,15 +157,15 @@ class File(object, metaclass=ABCMeta):
                     self._fuzzy_hash = None
             return self._fuzzy_hash
 
-    @abstractmethod
+    @abc.abstractmethod
     def is_directory():
         raise NotImplementedError()
 
-    @abstractmethod
+    @abc.abstractmethod
     def is_symlink():
         raise NotImplementedError()
 
-    @abstractmethod
+    @abc.abstractmethod
     def is_device():
         raise NotImplementedError()
 
@@ -258,7 +261,7 @@ class FilesystemFile(File):
 
     def is_device(self):
         mode = os.lstat(self._name).st_mode
-        return S_ISCHR(mode) or S_ISBLK(mode)
+        return stat.S_ISCHR(mode) or stat.S_ISBLK(mode)
 
 
 class NonExistingFile(File):
diff --git a/diffoscope/comparators/bzip2.py b/diffoscope/comparators/bzip2.py
index 9f8e42d..56c9abc 100644
--- a/diffoscope/comparators/bzip2.py
+++ b/diffoscope/comparators/bzip2.py
@@ -17,13 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from collections import OrderedDict
-import os.path
 import re
+import os.path
 import subprocess
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Archive, get_compressed_content_name
+import collections
+
 from diffoscope import logger, tool_required
+from diffoscope.comparators.utils import Archive, get_compressed_content_name
+from diffoscope.comparators.binary import File
 
 
 class Bzip2Container(Archive):
@@ -34,7 +35,7 @@ class Bzip2Container(Archive):
         pass
 
     def get_members(self):
-        return OrderedDict({'bzip2-content': self.get_member(self.get_member_names()[0])})
+        return collections.OrderedDict({'bzip2-content': self.get_member(self.get_member_names()[0])})
 
     def get_member_names(self):
         return [get_compressed_content_name(self.source.path, '.bz2')]
diff --git a/diffoscope/comparators/cbfs.py b/diffoscope/comparators/cbfs.py
index 2176779..d20c3c1 100644
--- a/diffoscope/comparators/cbfs.py
+++ b/diffoscope/comparators/cbfs.py
@@ -19,14 +19,14 @@
 
 import io
 import os
-import os.path
 import re
-import subprocess
 import struct
+import subprocess
+
 from diffoscope import logger, tool_required
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Archive, Command
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Archive, Command
+from diffoscope.comparators.binary import File
 
 
 class CbfsListing(Command):
diff --git a/diffoscope/comparators/cpio.py b/diffoscope/comparators/cpio.py
index a257090..bba3ecc 100644
--- a/diffoscope/comparators/cpio.py
+++ b/diffoscope/comparators/cpio.py
@@ -19,11 +19,12 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
+
 from diffoscope import tool_required
+from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Command
 from diffoscope.comparators.binary import File
 from diffoscope.comparators.libarchive import LibarchiveContainer, list_libarchive
-from diffoscope.comparators.utils import Command
-from diffoscope.difference import Difference
 
 
 class CpioContent(Command):
diff --git a/diffoscope/comparators/deb.py b/diffoscope/comparators/deb.py
index 978463d..43cf58f 100644
--- a/diffoscope/comparators/deb.py
+++ b/diffoscope/comparators/deb.py
@@ -18,18 +18,20 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
-try:
-    from debian import deb822
-except ImportError:
-    deb822 = None
+
 from diffoscope import logger
 from diffoscope.difference import Difference
-import diffoscope.comparators
+from diffoscope.comparators.tar import TarContainer
+from diffoscope.comparators.utils import ArchiveMember
 from diffoscope.comparators.binary import File
 from diffoscope.comparators.libarchive import LibarchiveContainer, list_libarchive
-from diffoscope.comparators.utils import \
-    ArchiveMember
-from diffoscope.comparators.tar import TarContainer
+
+import diffoscope.comparators
+
+try:
+    from debian import deb822
+except ImportError:
+    deb822 = None
 
 
 # Return a dict with build ids as keys and file as values for all deb in the
diff --git a/diffoscope/comparators/debian.py b/diffoscope/comparators/debian.py
index 3dadc5f..70bf33e 100644
--- a/diffoscope/comparators/debian.py
+++ b/diffoscope/comparators/debian.py
@@ -17,16 +17,18 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from collections import OrderedDict
-from functools import partial
-import hashlib
-import os.path
 import re
+import os.path
+import hashlib
+import functools
+import collections
+
 from debian.deb822 import Dsc
+
 from diffoscope.changes import Changes
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Container
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Container
+from diffoscope.comparators.binary import File
 
 
 DOT_CHANGES_FIELDS = [
@@ -82,7 +84,7 @@ class DebControlContainer(Container):
             return re.compile(re.escape(version))
 
     def get_members(self):
-        return OrderedDict([(self._trim_version_number(name), self.get_member(name)) for name in self.get_member_names()])
+        return collections.OrderedDict([(self._trim_version_number(name), self.get_member(name)) for name in self.get_member_names()])
 
     def get_member_names(self):
         field = self.source.deb822.get('Files') or self.source.deb822.get('Checksums-Sha256')
@@ -160,7 +162,7 @@ class DotDscFile(DebControlFile):
                 if not os.path.exists(in_dsc_path):
                     return False
                 with open(in_dsc_path, 'rb') as f:
-                    for buf in iter(partial(f.read, 32768), b''):
+                    for buf in iter(functools.partial(f.read, 32768), b''):
                         md5.update(buf)
                 if md5.hexdigest() != d['md5sum']:
                     return False
@@ -187,7 +189,7 @@ class DotBuildinfoFile(DebControlFile):
                 if not os.path.exists(in_buildinfo_path):
                     return False
                 with open(in_buildinfo_path, 'rb') as f:
-                    for buf in iter(partial(f.read, 32768), b''):
+                    for buf in iter(functools.partial(f.read, 32768), b''):
                         sha256.update(buf)
                 if sha256.hexdigest() != d['sha256']:
                     return False
diff --git a/diffoscope/comparators/debian_fallback.py b/diffoscope/comparators/debian_fallback.py
index 7bdaa61..98ab6cc 100644
--- a/diffoscope/comparators/debian_fallback.py
+++ b/diffoscope/comparators/debian_fallback.py
@@ -18,8 +18,10 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
+
 from diffoscope.comparators.text import TextFile
 
+
 class DotChangesFile(TextFile):
     RE_FILE_EXTENSION = re.compile(r'\.changes$')
 
diff --git a/diffoscope/comparators/device.py b/diffoscope/comparators/device.py
index 059a118..b59b765 100644
--- a/diffoscope/comparators/device.py
+++ b/diffoscope/comparators/device.py
@@ -18,10 +18,11 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
-from diffoscope.comparators.binary import File, FilesystemFile
-from diffoscope.comparators.utils import format_device
+
+from diffoscope import get_named_temporary_file
 from diffoscope.difference import Difference
-from diffoscope import logger, get_named_temporary_file
+from diffoscope.comparators.utils import format_device
+from diffoscope.comparators.binary import File, FilesystemFile
 
 
 class Device(File):
diff --git a/diffoscope/comparators/dex.py b/diffoscope/comparators/dex.py
index 48420bb..0693755 100644
--- a/diffoscope/comparators/dex.py
+++ b/diffoscope/comparators/dex.py
@@ -17,10 +17,11 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from collections import OrderedDict
 import re
 import os.path
 import subprocess
+import collections
+
 from diffoscope import logger, tool_required
 from diffoscope.comparators.binary import File
 from diffoscope.comparators.utils import Archive, get_compressed_content_name
@@ -38,7 +39,7 @@ class DexContainer(Archive):
         pass
 
     def get_members(self):
-        return OrderedDict({'dex-content': self.get_member(self.get_member_names()[0])})
+        return collections.OrderedDict({'dex-content': self.get_member(self.get_member_names()[0])})
 
     def get_member_names(self):
         return [get_compressed_content_name(self.source.path, '.dex') + '.jar']
diff --git a/diffoscope/comparators/directory.py b/diffoscope/comparators/directory.py
index 779624e..856a0e9 100644
--- a/diffoscope/comparators/directory.py
+++ b/diffoscope/comparators/directory.py
@@ -18,14 +18,15 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
-import os.path
 import re
 import subprocess
+
+import diffoscope.comparators
+
 from diffoscope import logger, tool_required, RequiredToolNotFound
 from diffoscope.difference import Difference
-import diffoscope.comparators
-from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils import Container, Command
+from diffoscope.comparators.binary import FilesystemFile
 
 
 def list_files(path):
diff --git a/diffoscope/comparators/elf.py b/diffoscope/comparators/elf.py
index e39b939..84d74fe 100644
--- a/diffoscope/comparators/elf.py
+++ b/diffoscope/comparators/elf.py
@@ -17,17 +17,18 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from collections import OrderedDict
-import os.path
 import re
+import os.path
 import subprocess
-from diffoscope import tool_required, OutputParsingError
-from diffoscope import logger, get_named_temporary_file
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.libarchive import list_libarchive
+import collections
+
+from diffoscope import tool_required, OutputParsingError, logger, \
+    get_named_temporary_file
+from diffoscope.difference import Difference
 from diffoscope.comparators.deb import DebFile, get_build_id_map
 from diffoscope.comparators.utils import Command, Container
-from diffoscope.difference import Difference
+from diffoscope.comparators.binary import File
+from diffoscope.comparators.libarchive import list_libarchive
 
 
 class Readelf(Command):
@@ -335,7 +336,7 @@ class ElfContainer(Container):
                 output = output[2:]
             output = output[5:]
 
-            self._sections = OrderedDict()
+            self._sections = collections.OrderedDict()
             # Entires of readelf --section-headers have the following columns:
             # [Nr]  Name  Type  Address  Off  Size  ES  Flg  Lk  Inf  Al
             for line in output:
diff --git a/diffoscope/comparators/fonts.py b/diffoscope/comparators/fonts.py
index 187655a..81f8d9e 100644
--- a/diffoscope/comparators/fonts.py
+++ b/diffoscope/comparators/fonts.py
@@ -18,10 +18,11 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
+
 from diffoscope import tool_required
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Command
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Command
+from diffoscope.comparators.binary import File
 
 
 class Showttf(Command):
diff --git a/diffoscope/comparators/fsimage.py b/diffoscope/comparators/fsimage.py
index 592312e..ca539cd 100644
--- a/diffoscope/comparators/fsimage.py
+++ b/diffoscope/comparators/fsimage.py
@@ -17,17 +17,19 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from collections import OrderedDict
 import re
 import os.path
+import collections
+
+from diffoscope import logger
+from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Archive
+from diffoscope.comparators.binary import File
+
 try:
     import guestfs
 except ImportError:
     guestfs = None
-from diffoscope import logger
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Archive
-from diffoscope.difference import Difference
 
 
 class FsImageContainer(Archive):
@@ -55,7 +57,7 @@ class FsImageContainer(Archive):
         self.g.close()
 
     def get_members(self):
-        return OrderedDict({'fsimage-content': self.get_member(self.get_member_names()[0])})
+        return collections.OrderedDict({'fsimage-content': self.get_member(self.get_member_names()[0])})
 
     def get_member_names(self):
         return [os.path.basename(self.source.path) + '.tar']
diff --git a/diffoscope/comparators/gettext.py b/diffoscope/comparators/gettext.py
index b739900..ede3b5d 100644
--- a/diffoscope/comparators/gettext.py
+++ b/diffoscope/comparators/gettext.py
@@ -17,13 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from io import BytesIO
+import io
 import re
+
+from diffoscope import logger
 from diffoscope import tool_required
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Command
 from diffoscope.difference import Difference
-from diffoscope import logger
+from diffoscope.comparators.utils import Command
+from diffoscope.comparators.binary import File
 
 
 class Msgunfmt(Command):
@@ -31,7 +32,7 @@ class Msgunfmt(Command):
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
-        self._header = BytesIO()
+        self._header = io.BytesIO()
         self._encoding = None
 
     @tool_required('msgunfmt')
diff --git a/diffoscope/comparators/gzip.py b/diffoscope/comparators/gzip.py
index 5ec244e..fff03e5 100644
--- a/diffoscope/comparators/gzip.py
+++ b/diffoscope/comparators/gzip.py
@@ -17,13 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from collections import OrderedDict
 import re
-import subprocess
 import os.path
+import subprocess
+import collections
+
 from diffoscope import logger, tool_required
-from diffoscope.comparators.utils import Archive, get_compressed_content_name
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Archive, get_compressed_content_name
 
 
 class GzipContainer(Archive):
@@ -34,7 +35,7 @@ class GzipContainer(Archive):
         pass
 
     def get_members(self):
-        return OrderedDict({'gzip-content': self.get_member(self.get_member_names()[0])})
+        return collections.OrderedDict({'gzip-content': self.get_member(self.get_member_names()[0])})
 
     def get_member_names(self):
         return [get_compressed_content_name(self.source.path, '.gz')]
diff --git a/diffoscope/comparators/haskell.py b/diffoscope/comparators/haskell.py
index 7bd4025..76c7b43 100644
--- a/diffoscope/comparators/haskell.py
+++ b/diffoscope/comparators/haskell.py
@@ -18,14 +18,14 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
-import platform
 import struct
+import platform
 import subprocess
-from diffoscope import tool_required
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Command
+
+from diffoscope import tool_required, logger
 from diffoscope.difference import Difference
-from diffoscope import logger
+from diffoscope.comparators.utils import Command
+from diffoscope.comparators.binary import File
 
 
 class ShowIface(Command):
diff --git a/diffoscope/comparators/icc.py b/diffoscope/comparators/icc.py
index d28b7d7..1356761 100644
--- a/diffoscope/comparators/icc.py
+++ b/diffoscope/comparators/icc.py
@@ -18,10 +18,11 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
+
 from diffoscope import tool_required
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Command
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Command
+from diffoscope.comparators.binary import File
 
 
 class Iccdump(Command):
diff --git a/diffoscope/comparators/ipk.py b/diffoscope/comparators/ipk.py
index 6cde8c7..f2d3865 100644
--- a/diffoscope/comparators/ipk.py
+++ b/diffoscope/comparators/ipk.py
@@ -19,6 +19,7 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
+
 from diffoscope.comparators.gzip import GzipFile
 
 
diff --git a/diffoscope/comparators/iso9660.py b/diffoscope/comparators/iso9660.py
index 4cdd0d3..8c80cb1 100644
--- a/diffoscope/comparators/iso9660.py
+++ b/diffoscope/comparators/iso9660.py
@@ -19,11 +19,12 @@
 
 import re
 import subprocess
+
 from diffoscope import tool_required
+from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Command
 from diffoscope.comparators.binary import File
 from diffoscope.comparators.libarchive import LibarchiveContainer
-from diffoscope.comparators.utils import Command
-from diffoscope.difference import Difference
 
 
 @tool_required('isoinfo')
diff --git a/diffoscope/comparators/java.py b/diffoscope/comparators/java.py
index f8b6b5e..159be7b 100644
--- a/diffoscope/comparators/java.py
+++ b/diffoscope/comparators/java.py
@@ -18,12 +18,13 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import re
+import os.path
+
 from diffoscope import tool_required
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Command
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Command
+from diffoscope.comparators.binary import File
 
 
 class Javap(Command):
diff --git a/diffoscope/comparators/libarchive.py b/diffoscope/comparators/libarchive.py
index 7bbabdd..aad3969 100644
--- a/diffoscope/comparators/libarchive.py
+++ b/diffoscope/comparators/libarchive.py
@@ -18,15 +18,16 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 
-import ctypes
-import os.path
 import time
+import os.path
+import ctypes
 import libarchive
+
 from diffoscope import logger
+from diffoscope.comparators.utils import Archive, ArchiveMember
 from diffoscope.comparators.device import Device
-from diffoscope.comparators.directory import Directory
 from diffoscope.comparators.symlink import Symlink
-from diffoscope.comparators.utils import Archive, ArchiveMember
+from diffoscope.comparators.directory import Directory
 
 
 # Monkeypatch libarchive-c (<< 2.2)
diff --git a/diffoscope/comparators/llvm.py b/diffoscope/comparators/llvm.py
index a78019b..2292363 100644
--- a/diffoscope/comparators/llvm.py
+++ b/diffoscope/comparators/llvm.py
@@ -19,9 +19,9 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 from diffoscope import tool_required
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Command
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Command
+from diffoscope.comparators.binary import File
 
 
 class LlvmBcAnalyzer(Command):
diff --git a/diffoscope/comparators/macho.py b/diffoscope/comparators/macho.py
index a893fe8..fa83268 100644
--- a/diffoscope/comparators/macho.py
+++ b/diffoscope/comparators/macho.py
@@ -20,10 +20,11 @@
 
 import re
 import subprocess
+
 from diffoscope import tool_required
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Command
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Command
+from diffoscope.comparators.binary import File
 
 
 class Otool(Command):
diff --git a/diffoscope/comparators/mono.py b/diffoscope/comparators/mono.py
index cfbf87d..5a0d4e3 100644
--- a/diffoscope/comparators/mono.py
+++ b/diffoscope/comparators/mono.py
@@ -19,10 +19,11 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
+
 from diffoscope import tool_required
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Command
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Command
+from diffoscope.comparators.binary import File
 
 
 class Pedump(Command):
diff --git a/diffoscope/comparators/pdf.py b/diffoscope/comparators/pdf.py
index 7df3ff0..3325c36 100644
--- a/diffoscope/comparators/pdf.py
+++ b/diffoscope/comparators/pdf.py
@@ -18,10 +18,11 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
+
 from diffoscope import tool_required
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Command
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Command
+from diffoscope.comparators.binary import File
 
 
 class Pdftotext(Command):
diff --git a/diffoscope/comparators/png.py b/diffoscope/comparators/png.py
index 0328e33..0b26a74 100644
--- a/diffoscope/comparators/png.py
+++ b/diffoscope/comparators/png.py
@@ -17,12 +17,13 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from functools import partial
 import re
+import functools
+
 from diffoscope import tool_required
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Command
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Command
+from diffoscope.comparators.binary import File
 
 
 class Sng(Command):
@@ -32,7 +33,7 @@ class Sng(Command):
 
     def feed_stdin(self, stdin):
         with open(self.path, 'rb') as f:
-            for buf in iter(partial(f.read, 32768), b''):
+            for buf in iter(functools.partial(f.read, 32768), b''):
                 stdin.write(buf)
 
 
diff --git a/diffoscope/comparators/ppu.py b/diffoscope/comparators/ppu.py
index 4fdbb32..2af4bc0 100644
--- a/diffoscope/comparators/ppu.py
+++ b/diffoscope/comparators/ppu.py
@@ -22,10 +22,11 @@
 import os
 import re
 import subprocess
+
 from diffoscope import tool_required, logger
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Command
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Command
+from diffoscope.comparators.binary import File
 
 
 class Ppudump(Command):
diff --git a/diffoscope/comparators/ps.py b/diffoscope/comparators/ps.py
index 98149d9..f0dd02b 100644
--- a/diffoscope/comparators/ps.py
+++ b/diffoscope/comparators/ps.py
@@ -18,10 +18,11 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
+
 from diffoscope import tool_required, RequiredToolNotFound, logger
+from diffoscope.difference import Difference
 from diffoscope.comparators.text import TextFile
 from diffoscope.comparators.utils import Command
-from diffoscope.difference import Difference
 
 
 class Pstotext(Command):
diff --git a/diffoscope/comparators/rpm.py b/diffoscope/comparators/rpm.py
index 4fbb939..a7fee08 100644
--- a/diffoscope/comparators/rpm.py
+++ b/diffoscope/comparators/rpm.py
@@ -18,15 +18,17 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from binascii import hexlify
-from io import StringIO
+import io
+import rpm
 import os.path
+import binascii
 import subprocess
-import rpm
+
 from diffoscope import logger, tool_required, get_temporary_directory
-from diffoscope.comparators.rpm_fallback import AbstractRpmFile
-from diffoscope.comparators.utils import Archive
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Archive
+from diffoscope.comparators.rpm_fallback import AbstractRpmFile
+
 
 def convert_header_field(io, header):
     if isinstance(header, list):
@@ -43,13 +45,13 @@ def convert_header_field(io, header):
         try:
             io.write(header.decode('utf-8'))
         except UnicodeDecodeError:
-            io.write(hexlify(header).decode('us-ascii'))
+            io.write(binascii.hexlify(header).decode('us-ascii'))
     else:
         io.write(repr(header))
 
 
 def get_rpm_header(path, ts):
-    s = StringIO()
+    s = io.StringIO()
     with open(path, 'r') as f:
         try:
             hdr = ts.hdrFromFdno(f)
diff --git a/diffoscope/comparators/rpm_fallback.py b/diffoscope/comparators/rpm_fallback.py
index 9ced3bd..08c31af 100644
--- a/diffoscope/comparators/rpm_fallback.py
+++ b/diffoscope/comparators/rpm_fallback.py
@@ -18,8 +18,10 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
+
 from diffoscope.comparators.binary import File
 
+
 class AbstractRpmFile(File):
     RE_FILE_TYPE = re.compile('^RPM\s')
 
diff --git a/diffoscope/comparators/rust.py b/diffoscope/comparators/rust.py
index 7a92728..e8f9cd8 100644
--- a/diffoscope/comparators/rust.py
+++ b/diffoscope/comparators/rust.py
@@ -18,14 +18,13 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from collections import OrderedDict
-import re
-import subprocess
-import os.path
 import zlib
+import os.path
+import collections
+
 from diffoscope import logger, tool_required
-from diffoscope.comparators.utils import Archive, get_compressed_content_name
 from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Archive, get_compressed_content_name
 
 
 RLIB_BYTECODE_OBJECT_V1_DATASIZE_OFFSET = 15
@@ -41,7 +40,7 @@ class RustObjectContainer(Archive):
         pass
 
     def get_members(self):
-        return OrderedDict({'deflate-content': self.get_member(self.get_member_names()[0])})
+        return collections.OrderedDict({'deflate-content': self.get_member(self.get_member_names()[0])})
 
     def get_member_names(self):
         return [get_compressed_content_name(self.source.path, '.deflate')]
diff --git a/diffoscope/comparators/sqlite.py b/diffoscope/comparators/sqlite.py
index 16706d7..5790bf4 100644
--- a/diffoscope/comparators/sqlite.py
+++ b/diffoscope/comparators/sqlite.py
@@ -18,9 +18,9 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 from diffoscope import tool_required
+from diffoscope.difference import Difference
 from diffoscope.comparators.binary import File
 from diffoscope.comparators.utils import Command
-from diffoscope.difference import Difference
 
 
 class Sqlite3Dump(Command):
diff --git a/diffoscope/comparators/squashfs.py b/diffoscope/comparators/squashfs.py
index 73c19b9..4911ccc 100644
--- a/diffoscope/comparators/squashfs.py
+++ b/diffoscope/comparators/squashfs.py
@@ -18,17 +18,18 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from collections import OrderedDict
 import re
-import subprocess
 import stat
+import subprocess
+import collections
+
 from diffoscope import logger, tool_required
+from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Archive, ArchiveMember, Command
 from diffoscope.comparators.binary import File
 from diffoscope.comparators.device import Device
-from diffoscope.comparators.directory import Directory
 from diffoscope.comparators.symlink import Symlink
-from diffoscope.comparators.utils import Archive, ArchiveMember, Command
-from diffoscope.difference import Difference
+from diffoscope.comparators.directory import Directory
 
 
 class SquashfsSuperblock(Command):
@@ -212,7 +213,7 @@ class SquashfsContainer(Archive):
                 logger.warning('Unknown squashfs entry: %s', line)
 
     def open_archive(self):
-        return OrderedDict([(kwargs['member_name'], (cls, kwargs)) for cls, kwargs in self.entries(self.source.path)])
+        return collections.OrderedDict([(kwargs['member_name'], (cls, kwargs)) for cls, kwargs in self.entries(self.source.path)])
 
     def close_archive(self):
         pass
diff --git a/diffoscope/comparators/symlink.py b/diffoscope/comparators/symlink.py
index bfe30a9..0e0a1d4 100644
--- a/diffoscope/comparators/symlink.py
+++ b/diffoscope/comparators/symlink.py
@@ -18,10 +18,11 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
+
+from diffoscope import logger, get_named_temporary_file
+from diffoscope.difference import Difference
 from diffoscope.comparators.binary import File
 from diffoscope.comparators.utils import format_symlink
-from diffoscope.difference import Difference
-from diffoscope import logger, get_named_temporary_file
 
 
 class Symlink(File):
diff --git a/diffoscope/comparators/tar.py b/diffoscope/comparators/tar.py
index 8b4cc5a..36fd229 100644
--- a/diffoscope/comparators/tar.py
+++ b/diffoscope/comparators/tar.py
@@ -18,9 +18,11 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
+
 from diffoscope.difference import Difference
 from diffoscope.comparators.binary import File
-from diffoscope.comparators.libarchive import LibarchiveContainer, list_libarchive
+from diffoscope.comparators.libarchive import LibarchiveContainer, \
+    list_libarchive
 
 class TarContainer(LibarchiveContainer):
     pass
diff --git a/diffoscope/comparators/text.py b/diffoscope/comparators/text.py
index a48a50e..45aaa4d 100644
--- a/diffoscope/comparators/text.py
+++ b/diffoscope/comparators/text.py
@@ -17,10 +17,11 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import codecs
 import re
-from diffoscope.comparators.binary import File
+import codecs
+
 from diffoscope.difference import Difference
+from diffoscope.comparators.binary import File
 
 
 class TextFile(File):
diff --git a/diffoscope/comparators/utils.py b/diffoscope/comparators/utils.py
index 7e9968a..95bff29 100644
--- a/diffoscope/comparators/utils.py
+++ b/diffoscope/comparators/utils.py
@@ -17,23 +17,24 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from abc import ABCMeta, abstractmethod
-from collections import OrderedDict
-from io import BytesIO
-from itertools import starmap
-# The following would be shutil.which in Python 3.3
+import abc
 import os
 import re
-from stat import S_ISCHR, S_ISBLK
+import io
+import stat
+import threading
+import itertools
 import subprocess
-from threading import Thread
+import collections
+
 import diffoscope.comparators
-from diffoscope.comparators.binary import File, NonExistingFile
-from diffoscope.config import Config
+
 from diffoscope import logger, tool_required, get_temporary_directory
+from diffoscope.config import Config
+from diffoscope.comparators.binary import File, NonExistingFile
 
 
-class Command(object, metaclass=ABCMeta):
+class Command(object, metaclass=abc.ABCMeta):
     def __init__(self, path):
         self._path = path
         logger.debug('running %s', self.cmdline())
@@ -44,15 +45,15 @@ class Command(object, metaclass=ABCMeta):
                                          stdout=subprocess.PIPE,
                                          stderr=subprocess.PIPE)
         if hasattr(self, 'feed_stdin'):
-            self._stdin_feeder = Thread(target=self._feed_stdin, args=(self._process.stdin,))
+            self._stdin_feeder = threading.Thread(target=self._feed_stdin, args=(self._process.stdin,))
             self._stdin_feeder.daemon = True
             self._stdin_feeder.start()
         else:
             self._stdin_feeder = None
             self._process.stdin.close()
-        self._stderr = BytesIO()
+        self._stderr = io.BytesIO()
         self._stderr_line_count = 0
-        self._stderr_reader = Thread(target=self._read_stderr)
+        self._stderr_reader = threading.Thread(target=self._read_stderr)
         self._stderr_reader.daemon = True
         self._stderr_reader.start()
 
@@ -60,7 +61,7 @@ class Command(object, metaclass=ABCMeta):
     def path(self):
         return self._path
 
-    @abstractmethod
+    @abc.abstractmethod
     def cmdline(self):
         raise NotImplementedError()
 
@@ -125,9 +126,9 @@ def format_symlink(destination):
 
 
 def format_device(mode, major, minor):
-    if S_ISCHR(mode):
+    if stat.S_ISCHR(mode):
         kind = 'character'
-    elif S_ISBLK(mode):
+    elif stat.S_ISBLK(mode):
         kind = 'block'
     else:
         kind = 'weird'
@@ -152,7 +153,7 @@ def diff_ignore_line_numbers(diff):
 NO_COMMENT = None
 
 
-class Container(object, metaclass=ABCMeta):
+class Container(object, metaclass=abc.ABCMeta):
     def __new__(cls, source):
         if isinstance(source, NonExistingFile):
             new = super(Container, NonExistingContainer).__new__(NonExistingContainer)
@@ -170,7 +171,7 @@ class Container(object, metaclass=ABCMeta):
 
     def get_members(self):
         """Returns a directory. The key is what is used to match when comparing containers."""
-        return OrderedDict([(name, self.get_member(name)) for name in self.get_member_names()])
+        return collections.OrderedDict([(name, self.get_member(name)) for name in self.get_member_names()])
 
     def lookup_file(self, *names):
         """Try to fetch a specific file by digging in containers."""
@@ -188,17 +189,17 @@ class Container(object, metaclass=ABCMeta):
             return None
         return container.lookup_file(*remainings)
 
-    @abstractmethod
+    @abc.abstractmethod
     def get_member_names(self):
         raise NotImplementedError()
 
-    @abstractmethod
+    @abc.abstractmethod
     def get_member(self, member_name):
         raise NotImplementedError()
 
     def comparisons(self, other):
         my_members = self.get_members()
-        my_reminders = OrderedDict()
+        my_reminders = collections.OrderedDict()
         other_members = other.get_members()
         # keep it sorted like my members
         while my_members:
@@ -218,7 +219,7 @@ class Container(object, metaclass=ABCMeta):
                 yield NonExistingFile('/dev/null', other_member), other_member, NO_COMMENT
 
     def compare(self, other, source=None):
-        return starmap(diffoscope.comparators.compare_commented_files, self.comparisons(other))
+        return itertools.starmap(diffoscope.comparators.compare_commented_files, self.comparisons(other))
 
 
 class NonExistingContainer(Container):
@@ -263,7 +264,7 @@ class ArchiveMember(File):
         return False
 
 
-class Archive(Container, metaclass=ABCMeta):
+class Archive(Container, metaclass=abc.ABCMeta):
     def __new__(cls, source, *args, **kwargs):
         if isinstance(source, NonExistingFile):
             return super(Container, NonExistingArchive).__new__(NonExistingArchive)
@@ -281,19 +282,19 @@ class Archive(Container, metaclass=ABCMeta):
     def archive(self):
         return self._archive
 
-    @abstractmethod
+    @abc.abstractmethod
     def open_archive(self):
         raise NotImplementedError()
 
-    @abstractmethod
+    @abc.abstractmethod
     def close_archive(self):
         raise NotImplementedError()
 
-    @abstractmethod
+    @abc.abstractmethod
     def get_member_names(self):
         raise NotImplementedError()
 
-    @abstractmethod
+    @abc.abstractmethod
     def extract(self, member_name, dest_dir):
         raise NotImplementedError()
 
diff --git a/diffoscope/comparators/xz.py b/diffoscope/comparators/xz.py
index 81251dc..8844898 100644
--- a/diffoscope/comparators/xz.py
+++ b/diffoscope/comparators/xz.py
@@ -17,13 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from collections import OrderedDict
-import os.path
 import re
+import os.path
 import subprocess
-from diffoscope.comparators.binary import File
-from diffoscope.comparators.utils import Archive, get_compressed_content_name
+import collections
+
 from diffoscope import logger, tool_required
+from diffoscope.comparators.utils import Archive, get_compressed_content_name
+from diffoscope.comparators.binary import File
 
 
 class XzContainer(Archive):
@@ -34,7 +35,7 @@ class XzContainer(Archive):
         pass
 
     def get_members(self):
-        return OrderedDict({'xz-content': self.get_member(self.get_member_names()[0])})
+        return collections.OrderedDict({'xz-content': self.get_member(self.get_member_names()[0])})
 
     def get_member_names(self):
         return [get_compressed_content_name(self.source.path, '.xz')]
diff --git a/diffoscope/comparators/zip.py b/diffoscope/comparators/zip.py
index 42c9a9f..6ca3783 100644
--- a/diffoscope/comparators/zip.py
+++ b/diffoscope/comparators/zip.py
@@ -17,17 +17,18 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from contextlib import contextmanager
-import os.path
 import re
-import shutil
 import sys
+import shutil
+import os.path
 import zipfile
-from diffoscope.difference import Difference
+import contextlib
+
 from diffoscope import tool_required
+from diffoscope.difference import Difference
+from diffoscope.comparators.utils import Archive, ArchiveMember, Command
 from diffoscope.comparators.binary import File
 from diffoscope.comparators.directory import Directory
-from diffoscope.comparators.utils import Archive, ArchiveMember, Command
 
 
 class Zipinfo(Command):
@@ -58,7 +59,7 @@ class ZipDirectory(Directory, ArchiveMember):
     def has_same_content_as(self, other):
         return False
 
-    @contextmanager
+    @contextlib.contextmanager
     def get_content(self):
         yield
 
diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index d333061..21ccc24 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -17,18 +17,19 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from contextlib import contextmanager
-import hashlib
-from io import StringIO
 import os
-import os.path
 import re
+import io
 import signal
+import hashlib
+import threading
+import contextlib
 import subprocess
-from threading import Thread
+
 from multiprocessing.dummy import Queue
-from diffoscope.config import Config
+
 from diffoscope import logger, tool_required, RequiredToolNotFound
+from diffoscope.config import Config
 
 
 class DiffParser(object):
@@ -39,7 +40,7 @@ class DiffParser(object):
         self._end_nl_q1 = end_nl_q1
         self._end_nl_q2 = end_nl_q2
         self._action = self.read_headers
-        self._diff = StringIO()
+        self._diff = io.StringIO()
         self._success = False
         self._remaining_hunk_lines = None
         self._block_len = None
@@ -145,7 +146,7 @@ def run_diff(fd1, fd2, end_nl_q1, end_nl_q2):
     os.close(fd1)
     os.close(fd2)
     parser = DiffParser(p.stdout, end_nl_q1, end_nl_q2)
-    t_read = Thread(target=parser.parse)
+    t_read = threading.Thread(target=parser.parse)
     t_read.daemon = True
     t_read.start()
     t_read.join()
@@ -159,7 +160,7 @@ def run_diff(fd1, fd2, end_nl_q1, end_nl_q2):
 
 
 # inspired by https://stackoverflow.com/a/6874161
-class ExThread(Thread):
+class ExThread(threading.Thread):
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
         self.__status_queue = Queue()
@@ -193,7 +194,7 @@ def feed(feeder, f, end_nl_q):
         f.close()
 
 
- at contextmanager
+ at contextlib.contextmanager
 def fd_from_feeder(feeder, end_nl_q):
     pipe_r, pipe_w = os.pipe()
     outf = os.fdopen(pipe_w, 'wb')
diff --git a/diffoscope/main.py b/diffoscope/main.py
index a786283..25e8db3 100644
--- a/diffoscope/main.py
+++ b/diffoscope/main.py
@@ -19,28 +19,32 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import argparse
-from contextlib import contextmanager
-import logging
-import codecs
 import os
-import signal
 import sys
+import codecs
+import signal
+import logging
+import argparse
 import traceback
+import contextlib
+
+import diffoscope.comparators
+
+from diffoscope import logger, VERSION, set_locale, clean_all_temp_files
+from diffoscope.config import Config
+from diffoscope.presenters.html import output_html, output_html_directory, \
+    JQUERY_SYSTEM_LOCATIONS
+from diffoscope.presenters.text import output_text
+
 try:
     import tlsh
 except ImportError:
     tlsh = None
+
 try:
     import argcomplete
 except ImportError:
     argcomplete = None
-from diffoscope import logger, VERSION, set_locale, clean_all_temp_files
-import diffoscope.comparators
-from diffoscope.config import Config
-from diffoscope.presenters.html import output_html
-from diffoscope.presenters.html import output_html_directory, JQUERY_SYSTEM_LOCATIONS
-from diffoscope.presenters.text import output_text
 
 
 def create_parser():
@@ -108,7 +112,7 @@ def create_parser():
     return parser
 
 
- at contextmanager
+ at contextlib.contextmanager
 def make_printer(path):
     if path == '-':
         output = sys.stdout
diff --git a/diffoscope/presenters/html.py b/diffoscope/presenters/html.py
index 8ea26c9..13b2550 100644
--- a/diffoscope/presenters/html.py
+++ b/diffoscope/presenters/html.py
@@ -31,20 +31,22 @@
 # Dave Burt <dave (at) burt.id.au> (mainly for html theme)
 #
 
-import cgi
-from io import StringIO
+import io
+import os
 import re
+import cgi
 import sys
-import os
-import os.path
 import codecs
 import hashlib
-from contextlib import contextmanager
+import contextlib
+
 from xml.sax.saxutils import escape
+
 from diffoscope import logger, VERSION
 from diffoscope.config import Config
 from diffoscope.presenters.icon import FAVICON_BASE64
 
+
 # minimum line size, we add a zero-sized breakable space every
 # LINESIZE characters
 LINESIZE = 20
@@ -279,7 +281,7 @@ def linediff(s, t):
 
 def convert(s, ponct=0, tag=''):
     i = 0
-    t = StringIO()
+    t = io.StringIO()
     for c in s:
         # used by diffs
         if c == DIFFON:
@@ -569,7 +571,7 @@ def output_html(difference, css_url=None, print_func=None):
                    force=True)
     output_footer(print_func)
 
- at contextmanager
+ at contextlib.contextmanager
 def file_printer(directory, filename):
     with codecs.open(os.path.join(directory,filename), 'w', encoding='utf-8') as f:
         print_func = f.write
diff --git a/diffoscope/presenters/text.py b/diffoscope/presenters/text.py
index a9202b2..4f9398f 100644
--- a/diffoscope/presenters/text.py
+++ b/diffoscope/presenters/text.py
@@ -19,6 +19,7 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import sys
+
 from diffoscope import logger
 
 
diff --git a/setup.py b/setup.py
index 2444c4f..7b51cd3 100644
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,10 @@
 #!/usr/bin/env python3
 
 import sys
+import diffoscope
+
 from setuptools import setup, find_packages
 from setuptools.command.test import test as TestCommand
-import diffoscope
 
 class PyTest(TestCommand):
     user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
diff --git a/tests/comparators/conftest.py b/tests/comparators/conftest.py
index 66276e0..b740bf0 100644
--- a/tests/comparators/conftest.py
+++ b/tests/comparators/conftest.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from distutils.spawn import find_executable
-from distutils.version import StrictVersion
-import diffoscope
 import pytest
+import diffoscope
 import subprocess
 
+from distutils.spawn import find_executable
+from distutils.version import StrictVersion
+
+
 @pytest.fixture(autouse=True)
 def set_locale():
     diffoscope.set_locale()
diff --git a/tests/comparators/test_binary.py b/tests/comparators/test_binary.py
index 34031b2..61b628f 100644
--- a/tests/comparators/test_binary.py
+++ b/tests/comparators/test_binary.py
@@ -17,14 +17,17 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
+import pytest
 import os.path
 import subprocess
-import pytest
-from diffoscope.comparators import specialize
+
 import diffoscope.comparators.binary
-from diffoscope.comparators.binary import File, FilesystemFile, NonExistingFile
-from diffoscope.difference import Difference
+
 from diffoscope import RequiredToolNotFound, tool_required
+from diffoscope.difference import Difference
+from diffoscope.comparators import specialize
+from diffoscope.comparators.binary import File, FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/binary1')
diff --git a/tests/comparators/test_bzip2.py b/tests/comparators/test_bzip2.py
index 84ab16a..2d52b80 100644
--- a/tests/comparators/test_bzip2.py
+++ b/tests/comparators/test_bzip2.py
@@ -17,20 +17,21 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import shutil
 import pytest
+import os.path
+
 from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.bzip2 import Bzip2File
 from diffoscope.config import Config
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.bz2')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.bz2')
 
 
-
 @pytest.fixture
 def bzip1():
     return specialize(FilesystemFile(TEST_FILE1_PATH))
diff --git a/tests/comparators/test_cbfs.py b/tests/comparators/test_cbfs.py
index 1850f76..12c8d19 100644
--- a/tests/comparators/test_cbfs.py
+++ b/tests/comparators/test_cbfs.py
@@ -18,14 +18,16 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
-from subprocess import check_call
 import struct
 import pytest
-from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
-from diffoscope.comparators.cbfs import CbfsFile
+import subprocess
+
 from diffoscope.config import Config
+from diffoscope.comparators import specialize
 from diffoscope.presenters.text import output_text
+from diffoscope.comparators.cbfs import CbfsFile
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/text_ascii1')
@@ -34,16 +36,16 @@ TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/text_ascii2')
 @pytest.fixture
 def rom1(tmpdir):
     path = str(tmpdir.join('coreboot1'))
-    check_call(['cbfstool', path, 'create', '-m', 'x86', '-s', '32768'], shell=False)
-    check_call(['cbfstool', path, 'add', '-f', TEST_FILE1_PATH, '-n', 'text', '-t', 'raw'], shell=False)
+    subprocess.check_call(['cbfstool', path, 'create', '-m', 'x86', '-s', '32768'], shell=False)
+    subprocess.check_call(['cbfstool', path, 'add', '-f', TEST_FILE1_PATH, '-n', 'text', '-t', 'raw'], shell=False)
     return specialize(FilesystemFile(path))
 
 @pytest.fixture
 def rom2(tmpdir):
     path = str(tmpdir.join('coreboot2.rom'))
     size = 32768
-    check_call(['cbfstool', path, 'create', '-m', 'x86', '-s', '%s' % size], shell=False)
-    check_call(['cbfstool', path, 'add', '-f', TEST_FILE2_PATH, '-n', 'text', '-t', 'raw'], shell=False)
+    subprocess.check_call(['cbfstool', path, 'create', '-m', 'x86', '-s', '%s' % size], shell=False)
+    subprocess.check_call(['cbfstool', path, 'add', '-f', TEST_FILE2_PATH, '-n', 'text', '-t', 'raw'], shell=False)
     # Remove the last 4 bytes to exercice the full header search
     buf = bytearray(size)
     with open(path, 'rb') as f:
diff --git a/tests/comparators/test_cpio.py b/tests/comparators/test_cpio.py
index 7fc0853..3efaa48 100644
--- a/tests/comparators/test_cpio.py
+++ b/tests/comparators/test_cpio.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.cpio import CpioFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.cpio')
diff --git a/tests/comparators/test_deb.py b/tests/comparators/test_deb.py
index fc57b69..dc784e4 100644
--- a/tests/comparators/test_deb.py
+++ b/tests/comparators/test_deb.py
@@ -17,14 +17,15 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
 import diffoscope.comparators
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.deb import DebFile, Md5sumsFile, DebDataTarFile
-from diffoscope.config import Config
-from conftest import tool_missing
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.deb')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.deb')
diff --git a/tests/comparators/test_debian.py b/tests/comparators/test_debian.py
index 86e70c2..6cb8abf 100644
--- a/tests/comparators/test_debian.py
+++ b/tests/comparators/test_debian.py
@@ -17,19 +17,22 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import shutil
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
+from diffoscope.presenters.text import output_text
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 try:
-    from diffoscope.comparators.debian import DotChangesFile, DotDscFile, DotBuildinfoFile
+    from diffoscope.comparators.debian import DotChangesFile, DotDscFile, \
+        DotBuildinfoFile
     miss_debian_module = False
 except ImportError:
     from diffoscope.comparators.debian_fallback import DotChangesFile, DotDscFile, DotBuildinfoFile
     miss_debian_module = True
-from diffoscope.config import Config
-from diffoscope.presenters.text import output_text
 
 TEST_DOT_CHANGES_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.changes')
 TEST_DOT_CHANGES_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.changes')
diff --git a/tests/comparators/test_dex.py b/tests/comparators/test_dex.py
index b815096..efcd136 100644
--- a/tests/comparators/test_dex.py
+++ b/tests/comparators/test_dex.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.dex import DexFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.dex')
diff --git a/tests/comparators/test_directory.py b/tests/comparators/test_directory.py
index 2e1cb4d..159e875 100644
--- a/tests/comparators/test_directory.py
+++ b/tests/comparators/test_directory.py
@@ -18,11 +18,11 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
-import os.path
 import shutil
 import pytest
-from diffoscope.comparators.directory import compare_directories
+
 from diffoscope.presenters.text import output_text
+from diffoscope.comparators.directory import compare_directories
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/text_ascii1')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/text_ascii2')
diff --git a/tests/comparators/test_elf.py b/tests/comparators/test_elf.py
index ece075b..1a263f7 100644
--- a/tests/comparators/test_elf.py
+++ b/tests/comparators/test_elf.py
@@ -17,20 +17,23 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
+from diffoscope.presenters.text import output_text
+from diffoscope.comparators.elf import ElfFile, StaticLibFile
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+from diffoscope.comparators.directory import FilesystemDirectory
+
+from conftest import tool_missing
+
 try:
-    import diffoscope.comparators.debian
+    import diffoscope.comparators.debian # noqa
     miss_debian_module = False
 except ImportError:
     miss_debian_module = True
-from diffoscope.comparators.directory import FilesystemDirectory
-from diffoscope.comparators.elf import ElfFile, StaticLibFile
-from diffoscope.config import Config
-from diffoscope.presenters.text import output_text
-from conftest import tool_missing
 
 TEST_OBJ1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.o')
 TEST_OBJ2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.o')
diff --git a/tests/comparators/test_epub.py b/tests/comparators/test_epub.py
index f99f10c..9dc9b3e 100644
--- a/tests/comparators/test_epub.py
+++ b/tests/comparators/test_epub.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.zip import ZipFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.epub')
diff --git a/tests/comparators/test_fonts.py b/tests/comparators/test_fonts.py
index 2bce45a..a420e4b 100644
--- a/tests/comparators/test_fonts.py
+++ b/tests/comparators/test_fonts.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.fonts import TtfFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/Samyak-Malayalam1.ttf')
diff --git a/tests/comparators/test_fsimage.py b/tests/comparators/test_fsimage.py
index d2305a3..c6b36af 100644
--- a/tests/comparators/test_fsimage.py
+++ b/tests/comparators/test_fsimage.py
@@ -17,18 +17,21 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
+from diffoscope.comparators import specialize
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+from diffoscope.comparators.fsimage import FsImageFile
+
+from conftest import tool_missing
+
 try:
     import guestfs
     miss_guestfs = False
 except ImportError:
     miss_guestfs = True
-from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
-from diffoscope.comparators.fsimage import FsImageFile
-from diffoscope.config import Config
-from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.ext4')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.ext4')
diff --git a/tests/comparators/test_gettext.py b/tests/comparators/test_gettext.py
index e592ca6..3f4129a 100644
--- a/tests/comparators/test_gettext.py
+++ b/tests/comparators/test_gettext.py
@@ -18,12 +18,14 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import codecs
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.gettext import MoFile
-from diffoscope.config import Config
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.mo')
diff --git a/tests/comparators/test_gzip.py b/tests/comparators/test_gzip.py
index 038398f..0cde843 100644
--- a/tests/comparators/test_gzip.py
+++ b/tests/comparators/test_gzip.py
@@ -20,10 +20,11 @@
 import os.path
 import shutil
 import pytest
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.gzip import GzipFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.gz')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.gz')
diff --git a/tests/comparators/test_icc.py b/tests/comparators/test_icc.py
index b08bc3e..e770de9 100644
--- a/tests/comparators/test_icc.py
+++ b/tests/comparators/test_icc.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.icc import IccFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.icc')
diff --git a/tests/comparators/test_image.py b/tests/comparators/test_image.py
index d48eae3..50b125f 100644
--- a/tests/comparators/test_image.py
+++ b/tests/comparators/test_image.py
@@ -20,11 +20,12 @@
 import pytest
 import os.path
 
-from conftest import tool_missing
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.image import ImageFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
+from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.jpg')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.jpg')
diff --git a/tests/comparators/test_ipk.py b/tests/comparators/test_ipk.py
index 2c3ae3a..0713c38 100644
--- a/tests/comparators/test_ipk.py
+++ b/tests/comparators/test_ipk.py
@@ -17,12 +17,13 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.ipk import IpkFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/base-files_157-r45695_ar71xx.ipk')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/base-files_157-r45918_ar71xx.ipk')
diff --git a/tests/comparators/test_iso9660.py b/tests/comparators/test_iso9660.py
index e4382e6..8a8b095 100644
--- a/tests/comparators/test_iso9660.py
+++ b/tests/comparators/test_iso9660.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.iso9660 import Iso9660File
-from diffoscope.config import Config
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.iso')
diff --git a/tests/comparators/test_java.py b/tests/comparators/test_java.py
index 8607881..069e8e0 100644
--- a/tests/comparators/test_java.py
+++ b/tests/comparators/test_java.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.java import ClassFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/Test1.class')
diff --git a/tests/comparators/test_macho.py b/tests/comparators/test_macho.py
index fcd5fcc..2bd862a 100644
--- a/tests/comparators/test_macho.py
+++ b/tests/comparators/test_macho.py
@@ -18,12 +18,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.macho import MachoFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_OBJ1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.macho')
diff --git a/tests/comparators/test_mono.py b/tests/comparators/test_mono.py
index 475b2e4..9d53a34 100644
--- a/tests/comparators/test_mono.py
+++ b/tests/comparators/test_mono.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.mono import MonoExeFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 # these were generated with:
diff --git a/tests/comparators/test_pdf.py b/tests/comparators/test_pdf.py
index 02ce5eb..659c41a 100644
--- a/tests/comparators/test_pdf.py
+++ b/tests/comparators/test_pdf.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.pdf import PdfFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.pdf')
diff --git a/tests/comparators/test_png.py b/tests/comparators/test_png.py
index 71e72bc..82bcdcd 100644
--- a/tests/comparators/test_png.py
+++ b/tests/comparators/test_png.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.png import PngFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.png')
diff --git a/tests/comparators/test_ppu.py b/tests/comparators/test_ppu.py
index eca9969..96be1a3 100644
--- a/tests/comparators/test_ppu.py
+++ b/tests/comparators/test_ppu.py
@@ -18,12 +18,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.ppu import PpuFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 # These test files were taken from two different builds of the Debian package
diff --git a/tests/comparators/test_ps.py b/tests/comparators/test_ps.py
index d0d49ba..22a27fb 100644
--- a/tests/comparators/test_ps.py
+++ b/tests/comparators/test_ps.py
@@ -19,10 +19,12 @@
 
 import os.path
 import pytest
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.ps import PsFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.ps')
diff --git a/tests/comparators/test_rlib.py b/tests/comparators/test_rlib.py
index 8e7f3dc..58cf2b4 100644
--- a/tests/comparators/test_rlib.py
+++ b/tests/comparators/test_rlib.py
@@ -18,16 +18,15 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
-import shutil
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.ar import ArFile
-from diffoscope.comparators.llvm import LlvmBitCodeFile
-from diffoscope.comparators.rust import RustObjectFile
 from diffoscope.comparators.utils import diff_ignore_line_numbers
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing, tool_older_than
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.rlib')
diff --git a/tests/comparators/test_rpm.py b/tests/comparators/test_rpm.py
index 5e9a715..84070dd 100644
--- a/tests/comparators/test_rpm.py
+++ b/tests/comparators/test_rpm.py
@@ -17,18 +17,21 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
+from conftest import tool_missing
+
 try:
     from diffoscope.comparators.rpm import RpmFile
     miss_rpm_module = False
 except ImportError:
     from diffoscope.comparators.rpm_fallback import RpmFile
     miss_rpm_module = True
-from diffoscope.config import Config
-from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.rpm')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.rpm')
diff --git a/tests/comparators/test_sqlite.py b/tests/comparators/test_sqlite.py
index de65eb4..c775e6d 100644
--- a/tests/comparators/test_sqlite.py
+++ b/tests/comparators/test_sqlite.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.sqlite import Sqlite3Database
-from diffoscope.config import Config
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.sqlite3')
diff --git a/tests/comparators/test_squashfs.py b/tests/comparators/test_squashfs.py
index 7ec7e07..42913c5 100644
--- a/tests/comparators/test_squashfs.py
+++ b/tests/comparators/test_squashfs.py
@@ -17,12 +17,14 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.squashfs import SquashfsFile
-from diffoscope.config import Config
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.squashfs')
diff --git a/tests/comparators/test_tar.py b/tests/comparators/test_tar.py
index 03fa07e..11dc88f 100644
--- a/tests/comparators/test_tar.py
+++ b/tests/comparators/test_tar.py
@@ -17,12 +17,13 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.tar import TarFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.tar')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.tar')
diff --git a/tests/comparators/test_text.py b/tests/comparators/test_text.py
index 147a906..b563811 100644
--- a/tests/comparators/test_text.py
+++ b/tests/comparators/test_text.py
@@ -18,11 +18,12 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import codecs
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
-from diffoscope.config import Config
 
 @pytest.fixture
 def ascii1():
diff --git a/tests/comparators/test_utils.py b/tests/comparators/test_utils.py
index aad8c2d..9eb2354 100644
--- a/tests/comparators/test_utils.py
+++ b/tests/comparators/test_utils.py
@@ -18,19 +18,23 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import codecs
-import os.path
 import pytest
+import os.path
+
+from diffoscope.config import Config
+from diffoscope.difference import Difference
+from diffoscope.comparators import specialize
+from diffoscope.comparators.utils import Command
+from diffoscope.comparators.binary import FilesystemFile
+
+from conftest import tool_missing
+
 try:
-    import tlsh
+    import tlsh # noqa
     miss_tlsh = False
 except ImportError:
     miss_tlsh = True
-from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
-from diffoscope.comparators.utils import Command
-from diffoscope.config import Config
-from diffoscope.difference import Difference
-from conftest import tool_missing
+
 
 @pytest.fixture
 def fuzzy_tar1():
diff --git a/tests/comparators/test_xz.py b/tests/comparators/test_xz.py
index a940ffd..239e4bc 100644
--- a/tests/comparators/test_xz.py
+++ b/tests/comparators/test_xz.py
@@ -17,13 +17,15 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
 import shutil
 import pytest
+import os.path
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.xz import XzFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.xz')
diff --git a/tests/comparators/test_zip.py b/tests/comparators/test_zip.py
index 57255bc..2f9177d 100644
--- a/tests/comparators/test_zip.py
+++ b/tests/comparators/test_zip.py
@@ -19,10 +19,12 @@
 
 import os.path
 import pytest
+
+from diffoscope.config import Config
 from diffoscope.comparators import specialize
-from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
 from diffoscope.comparators.zip import ZipFile, MozillaZipFile
-from diffoscope.config import Config
+from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
+
 from conftest import tool_missing
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.zip')
diff --git a/tests/test_difference.py b/tests/test_difference.py
index fffe3de..6a6cfa7 100644
--- a/tests/test_difference.py
+++ b/tests/test_difference.py
@@ -17,28 +17,30 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
-from io import StringIO
+import io
 import pytest
+
 from diffoscope.config import Config
 from diffoscope.difference import Difference
 
+
 def test_too_much_input_for_diff(monkeypatch):
     monkeypatch.setattr(Config, 'max_diff_input_lines', 20)
-    too_long_text_a = StringIO("a\n" * 21)
-    too_long_text_b = StringIO("b\n" * 21)
+    too_long_text_a = io.StringIO("a\n" * 21)
+    too_long_text_b = io.StringIO("b\n" * 21)
     difference = Difference.from_text_readers(too_long_text_a, too_long_text_b, 'a', 'b')
     assert '[ Too much input for diff ' in difference.unified_diff 
 
 def test_too_long_diff_block_lines(monkeypatch):
     monkeypatch.setattr(Config, 'max_diff_block_lines', 10)
-    too_long_text_a = StringIO("a\n" * 21)
-    too_long_text_b = StringIO("b\n" * 21)
+    too_long_text_a = io.StringIO("a\n" * 21)
+    too_long_text_b = io.StringIO("b\n" * 21)
     difference = Difference.from_text_readers(too_long_text_a, too_long_text_b, 'a', 'b')
     assert '[ 11 lines removed ]' in difference.unified_diff
 
 def test_non_str_arguments_to_source1_source2():
-    a = StringIO('a')
-    b = StringIO('b')
+    a = io.StringIO('a')
+    b = io.StringIO('b')
 
     with pytest.raises(TypeError):
         Difference.from_text_readers(a, b, a, b)
diff --git a/tests/test_main.py b/tests/test_main.py
index 90da5dd..7a5cd07 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -18,11 +18,13 @@
 # along with diffoscope.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
+import pytest
 import signal
 import tempfile
-import pytest
+
 from diffoscope.main import main
 
+
 def test_non_existing_files(capsys):
     args = '/nonexisting1 /nonexisting2'
     with pytest.raises(SystemExit) as excinfo:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list