diff --git a/.gitignore b/.gitignore
index 36f18d48..b36fcca5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ tasks.py
.ruffus_history.sqlite
.idea/
.pytest_cache/
+.pylintrc
# Package building
*.egg-info/
diff --git a/src/ocrmypdf/__main__.py b/src/ocrmypdf/__main__.py
index 2fff767a..fa992359 100755
--- a/src/ocrmypdf/__main__.py
+++ b/src/ocrmypdf/__main__.py
@@ -22,7 +22,6 @@ from pathlib import Path
import sys
import os
import re
-import multiprocessing
import atexit
import textwrap
import logging
diff --git a/src/ocrmypdf/exec/ghostscript.py b/src/ocrmypdf/exec/ghostscript.py
index b3a77c1b..1dd7ba42 100644
--- a/src/ocrmypdf/exec/ghostscript.py
+++ b/src/ocrmypdf/exec/ghostscript.py
@@ -16,14 +16,13 @@
# along with OCRmyPDF. If not, see .
from tempfile import NamedTemporaryFile
-from subprocess import run, PIPE, STDOUT, CalledProcessError
+from subprocess import run, PIPE, STDOUT
from shutil import copy
from functools import lru_cache
import re
-import sys
from PIL import Image
from . import get_version
-from ..exceptions import SubprocessOutputError, MissingDependencyError
+from ..exceptions import SubprocessOutputError
from ..helpers import fspath
diff --git a/src/ocrmypdf/exec/qpdf.py b/src/ocrmypdf/exec/qpdf.py
index 512f7aa3..a21b331b 100644
--- a/src/ocrmypdf/exec/qpdf.py
+++ b/src/ocrmypdf/exec/qpdf.py
@@ -17,15 +17,10 @@
from subprocess import CalledProcessError, STDOUT, PIPE, run
from functools import lru_cache
-import sys
-import os
-import re
-import resource
from ..exceptions import InputFileError, SubprocessOutputError, \
- MissingDependencyError, EncryptedPdfError
+ EncryptedPdfError
from . import get_version
-from ..helpers import re_symlink
@lru_cache(maxsize=1)
diff --git a/src/ocrmypdf/exec/tesseract.py b/src/ocrmypdf/exec/tesseract.py
index 3f1f4089..283916e4 100644
--- a/src/ocrmypdf/exec/tesseract.py
+++ b/src/ocrmypdf/exec/tesseract.py
@@ -17,13 +17,11 @@
import sys
import os
-import re
import shutil
from functools import lru_cache
from collections import namedtuple
from textwrap import dedent
-from subprocess import PIPE, CalledProcessError, \
- TimeoutExpired, check_output, STDOUT
+from subprocess import CalledProcessError, TimeoutExpired, check_output, STDOUT
from contextlib import suppress
from ..exceptions import MissingDependencyError, TesseractConfigError
diff --git a/src/ocrmypdf/helpers.py b/src/ocrmypdf/helpers.py
index 4d3d1349..11c95178 100644
--- a/src/ocrmypdf/helpers.py
+++ b/src/ocrmypdf/helpers.py
@@ -17,7 +17,7 @@
from functools import partial
from collections.abc import Iterable
-from contextlib import suppress, contextmanager
+from contextlib import suppress
from pathlib import Path
import sys
import os
diff --git a/src/ocrmypdf/hocrtransform.py b/src/ocrmypdf/hocrtransform.py
index edd674ff..26e5c906 100755
--- a/src/ocrmypdf/hocrtransform.py
+++ b/src/ocrmypdf/hocrtransform.py
@@ -16,10 +16,10 @@
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -31,7 +31,6 @@
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.units import inch
from xml.etree import ElementTree
-from PIL import Image
from collections import namedtuple
from math import atan, sin, cos
import re
diff --git a/src/ocrmypdf/leptonica.py b/src/ocrmypdf/leptonica.py
index 6ddbe02e..ea34ca3b 100644
--- a/src/ocrmypdf/leptonica.py
+++ b/src/ocrmypdf/leptonica.py
@@ -27,9 +27,9 @@ import logging
import warnings
from tempfile import TemporaryFile
from ctypes.util import find_library
-from .lib._leptonica import ffi
from functools import lru_cache
-from enum import Enum
+
+from .lib._leptonica import ffi
from .helpers import fspath
lept = ffi.dlopen(find_library('lept'))
@@ -635,4 +635,4 @@ if __name__ == '__main__':
parser_deskew.set_defaults(func=deskew)
args = parser.parse_args()
- args.func(args)
\ No newline at end of file
+ args.func(args)
diff --git a/src/ocrmypdf/optimize.py b/src/ocrmypdf/optimize.py
index 92273a9c..64bc3cdc 100644
--- a/src/ocrmypdf/optimize.py
+++ b/src/ocrmypdf/optimize.py
@@ -16,14 +16,11 @@
# along with OCRmyPDF. If not, see .
from pathlib import Path
-from subprocess import CalledProcessError
import concurrent.futures
from collections import defaultdict, namedtuple
-import struct
import logging
import sys
-from io import BytesIO
from PIL import Image
import pikepdf
diff --git a/src/ocrmypdf/pdfinfo.py b/src/ocrmypdf/pdfinfo.py
index a78d3c1c..af2b629d 100644
--- a/src/ocrmypdf/pdfinfo.py
+++ b/src/ocrmypdf/pdfinfo.py
@@ -16,17 +16,12 @@
# You should have received a copy of the GNU General Public License
# along with OCRmyPDF. If not, see .
-from subprocess import Popen, PIPE
from decimal import Decimal
from math import hypot, isclose
import re
-import sys
from collections import namedtuple
-from collections.abc import MutableMapping, Mapping
-import warnings
from pathlib import Path
from enum import Enum
-from contextlib import contextmanager
from .exec import ghostscript
from .helpers import fspath
diff --git a/src/ocrmypdf/pipeline.py b/src/ocrmypdf/pipeline.py
index 8ce930aa..a52e20d1 100644
--- a/src/ocrmypdf/pipeline.py
+++ b/src/ocrmypdf/pipeline.py
@@ -22,7 +22,6 @@ from datetime import datetime, timezone
import sys
import os
-import shutil
import re
import img2pdf
@@ -32,11 +31,11 @@ from PIL import Image
from ruffus import formatter, regex, Pipeline, suffix
from .hocrtransform import HocrTransform
-from .pdfinfo import PdfInfo, Encoding, Colorspace
+from .pdfinfo import PdfInfo, Colorspace
from .pdfa import generate_pdfa_ps, encode_pdf_date
from .helpers import re_symlink, is_iterable_notstr, page_number, flatten_groups
from .exec import ghostscript, tesseract, qpdf
-from .exceptions import PdfMergeFailedError, UnsupportedImageFormatError, \
+from .exceptions import UnsupportedImageFormatError, \
DpiError, PriorOcrFoundError, InputFileError
from . import leptonica
from . import PROGRAM_NAME, VERSION
diff --git a/tests/spoof/tesseract_cache.py b/tests/spoof/tesseract_cache.py
index 92366f2b..47ad93d9 100755
--- a/tests/spoof/tesseract_cache.py
+++ b/tests/spoof/tesseract_cache.py
@@ -20,18 +20,6 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-from pathlib import Path
-import sys
-import os
-import shutil
-import subprocess
-import argparse
-import json
-import platform
-import re
-
-
"""Cache output of tesseract to speed up test suite
The cache is keyed by an environment variable that slips the input test file
@@ -66,6 +54,16 @@ given.
"""
+from pathlib import Path
+import sys
+import os
+import shutil
+import subprocess
+import argparse
+import json
+import platform
+import re
+
if '_OCRMYPDF_SAVE_PATH' in os.environ:
os.environ['PATH'] = os.environ['_OCRMYPDF_SAVE_PATH']
diff --git a/tests/spoof/tesseract_noop.py b/tests/spoof/tesseract_noop.py
index 468fa326..aa56f4be 100755
--- a/tests/spoof/tesseract_noop.py
+++ b/tests/spoof/tesseract_noop.py
@@ -20,12 +20,6 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-import sys
-import img2pdf
-import PyPDF2 as pypdf
-from PIL import Image
-
-
"""Tesseract no-op spoof
To quickly run tests where getting OCR output is not necessary.
@@ -37,6 +31,11 @@ In 'pdf' mode, convert the image to PDF using another program.
In orientation check mode, report the orientation is upright.
"""
+import sys
+import img2pdf
+import PyPDF2 as pypdf
+from PIL import Image
+
VERSION_STRING = '''tesseract 3.05.01
leptonica-1.72
diff --git a/tests/test_hocrtransform.py b/tests/test_hocrtransform.py
index 3d02cf87..e40d3867 100644
--- a/tests/test_hocrtransform.py
+++ b/tests/test_hocrtransform.py
@@ -18,17 +18,11 @@
from ocrmypdf import hocrtransform
from ocrmypdf.exec.tesseract import HOCR_TEMPLATE
from ocrmypdf.exec import qpdf
-from reportlab.pdfgen.canvas import Canvas
from PIL import Image
-from tempfile import NamedTemporaryFile
-from contextlib import suppress
from pathlib import Path
-import os
-import shutil
import pytest
-import img2pdf
-import pytest
-import sys
+
+# pylint: disable=redefined-outer-name
@pytest.fixture
diff --git a/tests/test_main.py b/tests/test_main.py
index f0d4a917..55eb90c6 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -34,8 +34,7 @@ from ocrmypdf.pdfa import file_claims_pdfa
from ocrmypdf.leptonica import Pix
# pytest.helpers is dynamic
-# pylint: disable=no-member
-# pylint: disable=w0612
+# pylint: disable=no-member,redefined-outer-name
check_ocrmypdf = pytest.helpers.check_ocrmypdf
run_ocrmypdf = pytest.helpers.run_ocrmypdf
diff --git a/tests/test_optimize.py b/tests/test_optimize.py
index 586ff45f..ba196d9e 100644
--- a/tests/test_optimize.py
+++ b/tests/test_optimize.py
@@ -19,8 +19,6 @@ from pathlib import Path
import pytest
-import pikepdf
-
from ocrmypdf import optimize as opt