diff --git a/Tests/32bit_segfault_check.py b/Tests/32bit_segfault_check.py index 59a22c9d6..26a91d5cd 100755 --- a/Tests/32bit_segfault_check.py +++ b/Tests/32bit_segfault_check.py @@ -1,8 +1,8 @@ #!/usr/bin/env python -from PIL import Image import sys +from PIL import Image if sys.maxsize < 2 ** 32: im = Image.new("L", (999999, 999999), 0) diff --git a/Tests/bench_cffi_access.py b/Tests/bench_cffi_access.py index 249db3c9a..99c7006fa 100644 --- a/Tests/bench_cffi_access.py +++ b/Tests/bench_cffi_access.py @@ -1,10 +1,10 @@ -from .helper import unittest, PillowTestCase, hopper - -# Not running this test by default. No DOS against Travis CI. +import time from PIL import PyAccess -import time +from .helper import PillowTestCase, hopper, unittest + +# Not running this test by default. No DOS against Travis CI. def iterate_get(size, access): diff --git a/Tests/bench_get.py b/Tests/bench_get.py index 12d7d06fc..8a54ff921 100644 --- a/Tests/bench_get.py +++ b/Tests/bench_get.py @@ -1,7 +1,7 @@ -from . import helper +import sys import timeit -import sys +from . import helper sys.path.insert(0, ".") diff --git a/Tests/check_fli_overflow.py b/Tests/check_fli_overflow.py index 6b16f0371..db6559f1e 100644 --- a/Tests/check_fli_overflow.py +++ b/Tests/check_fli_overflow.py @@ -1,6 +1,7 @@ -from .helper import unittest, PillowTestCase from PIL import Image +from .helper import PillowTestCase, unittest + TEST_FILE = "Tests/images/fli_overflow.fli" diff --git a/Tests/check_icns_dos.py b/Tests/check_icns_dos.py index aaa13ddd2..03eda2e3f 100644 --- a/Tests/check_icns_dos.py +++ b/Tests/check_icns_dos.py @@ -1,9 +1,10 @@ # Tests potential DOS of IcnsImagePlugin with 0 length block. # Run from anywhere that PIL is importable. +from io import BytesIO + from PIL import Image from PIL._util import py3 -from io import BytesIO if py3: Image.open(BytesIO(bytes("icns\x00\x00\x00\x10hang\x00\x00\x00\x00", "latin-1"))) diff --git a/Tests/check_imaging_leaks.py b/Tests/check_imaging_leaks.py index e616f20f2..2b9a9605b 100755 --- a/Tests/check_imaging_leaks.py +++ b/Tests/check_imaging_leaks.py @@ -1,10 +1,13 @@ #!/usr/bin/env python from __future__ import division -from .helper import unittest, PillowTestCase + import sys + from PIL import Image +from .helper import PillowTestCase, unittest + min_iterations = 100 max_iterations = 10000 diff --git a/Tests/check_j2k_dos.py b/Tests/check_j2k_dos.py index e036f5dbd..7d0e95a60 100644 --- a/Tests/check_j2k_dos.py +++ b/Tests/check_j2k_dos.py @@ -1,9 +1,10 @@ # Tests potential DOS of Jpeg2kImagePlugin with 0 length block. # Run from anywhere that PIL is importable. +from io import BytesIO + from PIL import Image from PIL._util import py3 -from io import BytesIO if py3: Image.open( diff --git a/Tests/check_j2k_leaks.py b/Tests/check_j2k_leaks.py index 19aabc81b..4614529ed 100755 --- a/Tests/check_j2k_leaks.py +++ b/Tests/check_j2k_leaks.py @@ -1,8 +1,10 @@ -from .helper import unittest, PillowTestCase import sys -from PIL import Image from io import BytesIO +from PIL import Image + +from .helper import PillowTestCase, unittest + # Limits for testing the leak mem_limit = 1024 * 1048576 stack_size = 8 * 1048576 diff --git a/Tests/check_j2k_overflow.py b/Tests/check_j2k_overflow.py index 32bbdbf42..3e6cf8d34 100644 --- a/Tests/check_j2k_overflow.py +++ b/Tests/check_j2k_overflow.py @@ -1,5 +1,6 @@ from PIL import Image -from .helper import unittest, PillowTestCase + +from .helper import PillowTestCase, unittest class TestJ2kEncodeOverflow(PillowTestCase): diff --git a/Tests/check_jpeg_leaks.py b/Tests/check_jpeg_leaks.py index a6fd00280..2f758ba10 100644 --- a/Tests/check_jpeg_leaks.py +++ b/Tests/check_jpeg_leaks.py @@ -1,6 +1,7 @@ -from .helper import unittest, PillowTestCase, hopper -from io import BytesIO import sys +from io import BytesIO + +from .helper import PillowTestCase, hopper, unittest iterations = 5000 diff --git a/Tests/check_large_memory.py b/Tests/check_large_memory.py index 7e0e83088..5df476e0a 100644 --- a/Tests/check_large_memory.py +++ b/Tests/check_large_memory.py @@ -1,6 +1,8 @@ import sys -from .helper import unittest, PillowTestCase +from PIL import Image + +from .helper import PillowTestCase, unittest # This test is not run automatically. # @@ -11,7 +13,6 @@ from .helper import unittest, PillowTestCase # Raspberry Pis). It does succeed on a 3gb Ubuntu 12.04x64 VM on Python # 2.7 and 3.2. -from PIL import Image try: import numpy diff --git a/Tests/check_large_memory_numpy.py b/Tests/check_large_memory_numpy.py index 3607bcb97..4653a6013 100644 --- a/Tests/check_large_memory_numpy.py +++ b/Tests/check_large_memory_numpy.py @@ -1,6 +1,8 @@ import sys -from .helper import unittest, PillowTestCase +from PIL import Image + +from .helper import PillowTestCase, unittest # This test is not run automatically. # @@ -10,7 +12,6 @@ from .helper import unittest, PillowTestCase # on any 32-bit machine, as well as any smallish things (like # Raspberry Pis). -from PIL import Image try: import numpy as np diff --git a/Tests/check_libtiff_segfault.py b/Tests/check_libtiff_segfault.py index 99e3056bf..ae9a46d1b 100644 --- a/Tests/check_libtiff_segfault.py +++ b/Tests/check_libtiff_segfault.py @@ -1,6 +1,7 @@ -from .helper import unittest, PillowTestCase from PIL import Image +from .helper import PillowTestCase, unittest + TEST_FILE = "Tests/images/libtiff_segfault.tif" diff --git a/Tests/check_png_dos.py b/Tests/check_png_dos.py index edcb0d952..5c78ce122 100644 --- a/Tests/check_png_dos.py +++ b/Tests/check_png_dos.py @@ -1,7 +1,9 @@ -from .helper import unittest, PillowTestCase -from PIL import Image, PngImagePlugin, ImageFile -from io import BytesIO import zlib +from io import BytesIO + +from PIL import Image, ImageFile, PngImagePlugin + +from .helper import PillowTestCase, unittest TEST_FILE = "Tests/images/png_decompression_dos.png" diff --git a/Tests/createfontdatachunk.py b/Tests/createfontdatachunk.py index bace38a23..4d189dbad 100755 --- a/Tests/createfontdatachunk.py +++ b/Tests/createfontdatachunk.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function + import base64 import os diff --git a/Tests/helper.py b/Tests/helper.py index 7038566bf..9a41ce7df 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -2,16 +2,16 @@ Helper functions. """ from __future__ import print_function + +import logging +import os import sys import tempfile -import os import unittest from PIL import Image, ImageMath from PIL._util import py3 -import logging - logger = logging.getLogger(__name__) diff --git a/Tests/import_all.py b/Tests/import_all.py index ccfc53aef..4dfacb291 100644 --- a/Tests/import_all.py +++ b/Tests/import_all.py @@ -2,9 +2,8 @@ from __future__ import print_function import glob import os -import traceback - import sys +import traceback sys.path.insert(0, ".") diff --git a/Tests/test_000_sanity.py b/Tests/test_000_sanity.py index 0dccb6f59..a6143f084 100644 --- a/Tests/test_000_sanity.py +++ b/Tests/test_000_sanity.py @@ -1,8 +1,8 @@ -from .helper import PillowTestCase - import PIL import PIL.Image +from .helper import PillowTestCase + class TestSanity(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_binary.py b/Tests/test_binary.py index 8b46192cd..79d5d2bcb 100644 --- a/Tests/test_binary.py +++ b/Tests/test_binary.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import _binary +from .helper import PillowTestCase + class TestBinary(PillowTestCase): def test_standard(self): diff --git a/Tests/test_bmp_reference.py b/Tests/test_bmp_reference.py index fcdf20e5a..e6a75e2c3 100644 --- a/Tests/test_bmp_reference.py +++ b/Tests/test_bmp_reference.py @@ -1,8 +1,10 @@ from __future__ import print_function -from .helper import PillowTestCase + +import os from PIL import Image -import os + +from .helper import PillowTestCase base = os.path.join("Tests", "images", "bmp") diff --git a/Tests/test_box_blur.py b/Tests/test_box_blur.py index ae8985580..c17e7996d 100644 --- a/Tests/test_box_blur.py +++ b/Tests/test_box_blur.py @@ -1,7 +1,6 @@ -from .helper import PillowTestCase - from PIL import Image, ImageFilter +from .helper import PillowTestCase sample = Image.new("L", (7, 5)) # fmt: off diff --git a/Tests/test_color_lut.py b/Tests/test_color_lut.py index 6208b6a80..ca82209c2 100644 --- a/Tests/test_color_lut.py +++ b/Tests/test_color_lut.py @@ -3,7 +3,8 @@ from __future__ import division from array import array from PIL import Image, ImageFilter -from .helper import unittest, PillowTestCase + +from .helper import PillowTestCase, unittest try: import numpy diff --git a/Tests/test_core_resources.py b/Tests/test_core_resources.py index c8ba4b4d5..eefb1a0ef 100644 --- a/Tests/test_core_resources.py +++ b/Tests/test_core_resources.py @@ -2,9 +2,9 @@ from __future__ import division, print_function import sys -from .helper import unittest, PillowTestCase from PIL import Image +from .helper import PillowTestCase, unittest is_pypy = hasattr(sys, "pypy_version_info") diff --git a/Tests/test_decompression_bomb.py b/Tests/test_decompression_bomb.py index 6b224632d..b3a36fe78 100644 --- a/Tests/test_decompression_bomb.py +++ b/Tests/test_decompression_bomb.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + TEST_FILE = "Tests/images/hopper.ppm" ORIGINAL_LIMIT = Image.MAX_IMAGE_PIXELS diff --git a/Tests/test_features.py b/Tests/test_features.py index d7e505ac7..64b0302ca 100644 --- a/Tests/test_features.py +++ b/Tests/test_features.py @@ -2,10 +2,10 @@ from __future__ import unicode_literals import io -from .helper import unittest, PillowTestCase - from PIL import features +from .helper import PillowTestCase, unittest + try: from PIL import _webp diff --git a/Tests/test_file_bmp.py b/Tests/test_file_bmp.py index 71ea72751..2180835ba 100644 --- a/Tests/test_file_bmp.py +++ b/Tests/test_file_bmp.py @@ -1,8 +1,9 @@ -from .helper import PillowTestCase, hopper - -from PIL import Image, BmpImagePlugin import io +from PIL import BmpImagePlugin, Image + +from .helper import PillowTestCase, hopper + class TestFileBmp(PillowTestCase): def roundtrip(self, im): diff --git a/Tests/test_file_bufrstub.py b/Tests/test_file_bufrstub.py index eb59b2469..37573e340 100644 --- a/Tests/test_file_bufrstub.py +++ b/Tests/test_file_bufrstub.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import BufrStubImagePlugin, Image +from .helper import PillowTestCase, hopper + TEST_FILE = "Tests/images/gfs.t06z.rassda.tm00.bufr_d" diff --git a/Tests/test_file_container.py b/Tests/test_file_container.py index eb13d5f18..5f14001d9 100644 --- a/Tests/test_file_container.py +++ b/Tests/test_file_container.py @@ -1,7 +1,6 @@ -from .helper import PillowTestCase, hopper +from PIL import ContainerIO, Image -from PIL import Image -from PIL import ContainerIO +from .helper import PillowTestCase, hopper TEST_FILE = "Tests/images/dummy.container" diff --git a/Tests/test_file_cur.py b/Tests/test_file_cur.py index a2ffb2e60..0b2f7a98c 100644 --- a/Tests/test_file_cur.py +++ b/Tests/test_file_cur.py @@ -1,6 +1,6 @@ -from .helper import PillowTestCase +from PIL import CurImagePlugin, Image -from PIL import Image, CurImagePlugin +from .helper import PillowTestCase TEST_FILE = "Tests/images/deerstalker.cur" diff --git a/Tests/test_file_dcx.py b/Tests/test_file_dcx.py index 8e6ab111f..4d3690d30 100644 --- a/Tests/test_file_dcx.py +++ b/Tests/test_file_dcx.py @@ -1,6 +1,6 @@ -from .helper import PillowTestCase, hopper +from PIL import DcxImagePlugin, Image -from PIL import Image, DcxImagePlugin +from .helper import PillowTestCase, hopper # Created with ImageMagick: convert hopper.ppm hopper.dcx TEST_FILE = "Tests/images/hopper.dcx" diff --git a/Tests/test_file_dds.py b/Tests/test_file_dds.py index 80b452da2..498c64f21 100644 --- a/Tests/test_file_dds.py +++ b/Tests/test_file_dds.py @@ -1,7 +1,8 @@ from io import BytesIO +from PIL import DdsImagePlugin, Image + from .helper import PillowTestCase -from PIL import Image, DdsImagePlugin TEST_FILE_DXT1 = "Tests/images/dxt1-rgb-4bbp-noalpha_MipMaps-1.dds" TEST_FILE_DXT3 = "Tests/images/dxt3-argb-8bbp-explicitalpha_MipMaps-1.dds" diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py index 00736c38c..3459310df 100644 --- a/Tests/test_file_eps.py +++ b/Tests/test_file_eps.py @@ -1,8 +1,9 @@ -from .helper import unittest, PillowTestCase, hopper - -from PIL import Image, EpsImagePlugin import io +from PIL import EpsImagePlugin, Image + +from .helper import PillowTestCase, hopper, unittest + HAS_GHOSTSCRIPT = EpsImagePlugin.has_ghostscript() # Our two EPS test files (they are identical except for their bounding boxes) diff --git a/Tests/test_file_fitsstub.py b/Tests/test_file_fitsstub.py index 86ddecb9d..0221bab99 100644 --- a/Tests/test_file_fitsstub.py +++ b/Tests/test_file_fitsstub.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import FitsStubImagePlugin, Image +from .helper import PillowTestCase + TEST_FILE = "Tests/images/hopper.fits" diff --git a/Tests/test_file_fli.py b/Tests/test_file_fli.py index e5dadc3dc..ad3e84a5b 100644 --- a/Tests/test_file_fli.py +++ b/Tests/test_file_fli.py @@ -1,6 +1,6 @@ -from .helper import PillowTestCase +from PIL import FliImagePlugin, Image -from PIL import Image, FliImagePlugin +from .helper import PillowTestCase # created as an export of a palette image from Gimp2.6 # save as...-> hopper.fli, default options. diff --git a/Tests/test_file_fpx.py b/Tests/test_file_fpx.py index a426ca904..68412c8ca 100644 --- a/Tests/test_file_fpx.py +++ b/Tests/test_file_fpx.py @@ -1,4 +1,4 @@ -from .helper import unittest, PillowTestCase +from .helper import PillowTestCase, unittest try: from PIL import FpxImagePlugin diff --git a/Tests/test_file_ftex.py b/Tests/test_file_ftex.py index 16ecab2d1..7d30042ca 100644 --- a/Tests/test_file_ftex.py +++ b/Tests/test_file_ftex.py @@ -1,6 +1,7 @@ -from .helper import PillowTestCase from PIL import Image +from .helper import PillowTestCase + class TestFileFtex(PillowTestCase): def test_load_raw(self): diff --git a/Tests/test_file_gbr.py b/Tests/test_file_gbr.py index bdb52a6fa..659179a4e 100644 --- a/Tests/test_file_gbr.py +++ b/Tests/test_file_gbr.py @@ -1,6 +1,6 @@ -from .helper import PillowTestCase +from PIL import GbrImagePlugin, Image -from PIL import Image, GbrImagePlugin +from .helper import PillowTestCase class TestFileGbr(PillowTestCase): diff --git a/Tests/test_file_gd.py b/Tests/test_file_gd.py index 82b089a5f..6467d1e92 100644 --- a/Tests/test_file_gd.py +++ b/Tests/test_file_gd.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import GdImageFile +from .helper import PillowTestCase + TEST_GD_FILE = "Tests/images/hopper.gd" diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index 45409cbc6..2ba370c3f 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -1,9 +1,9 @@ -from .helper import unittest, PillowTestCase, hopper, netpbm_available - -from PIL import Image, ImagePalette, GifImagePlugin, ImageDraw - from io import BytesIO +from PIL import GifImagePlugin, Image, ImageDraw, ImagePalette + +from .helper import PillowTestCase, hopper, netpbm_available, unittest + try: from PIL import _webp diff --git a/Tests/test_file_gimpgradient.py b/Tests/test_file_gimpgradient.py index 14e0f3b38..bafee79a3 100644 --- a/Tests/test_file_gimpgradient.py +++ b/Tests/test_file_gimpgradient.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import GimpGradientFile +from .helper import PillowTestCase + class TestImage(PillowTestCase): def test_linear_pos_le_middle(self): diff --git a/Tests/test_file_gimppalette.py b/Tests/test_file_gimppalette.py index 973dd3060..a1677f0cb 100644 --- a/Tests/test_file_gimppalette.py +++ b/Tests/test_file_gimppalette.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL.GimpPaletteFile import GimpPaletteFile +from .helper import PillowTestCase + class TestImage(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_file_gribstub.py b/Tests/test_file_gribstub.py index 0f371778a..d322e1c70 100644 --- a/Tests/test_file_gribstub.py +++ b/Tests/test_file_gribstub.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import GribStubImagePlugin, Image +from .helper import PillowTestCase, hopper + TEST_FILE = "Tests/images/WAlaska.wind.7days.grb" diff --git a/Tests/test_file_hdf5stub.py b/Tests/test_file_hdf5stub.py index efb8de238..c300bae20 100644 --- a/Tests/test_file_hdf5stub.py +++ b/Tests/test_file_hdf5stub.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import Hdf5StubImagePlugin, Image +from .helper import PillowTestCase + TEST_FILE = "Tests/images/hdf5.h5" diff --git a/Tests/test_file_icns.py b/Tests/test_file_icns.py index 01ad34e04..2e33e0ae5 100644 --- a/Tests/test_file_icns.py +++ b/Tests/test_file_icns.py @@ -1,10 +1,10 @@ -from .helper import unittest, PillowTestCase - -from PIL import Image, IcnsImagePlugin - import io import sys +from PIL import IcnsImagePlugin, Image + +from .helper import PillowTestCase, unittest + # sample icon file TEST_FILE = "Tests/images/pillow.icns" diff --git a/Tests/test_file_ico.py b/Tests/test_file_ico.py index 8427e2bd7..8a01e417f 100644 --- a/Tests/test_file_ico.py +++ b/Tests/test_file_ico.py @@ -1,7 +1,8 @@ -from .helper import PillowTestCase, hopper - import io -from PIL import Image, ImageDraw, IcoImagePlugin + +from PIL import IcoImagePlugin, Image, ImageDraw + +from .helper import PillowTestCase, hopper TEST_ICO_FILE = "Tests/images/hopper.ico" diff --git a/Tests/test_file_im.py b/Tests/test_file_im.py index 2a89e39dc..90e26efd5 100644 --- a/Tests/test_file_im.py +++ b/Tests/test_file_im.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image, ImImagePlugin +from .helper import PillowTestCase, hopper + # sample im TEST_IM = "Tests/images/hopper.im" diff --git a/Tests/test_file_iptc.py b/Tests/test_file_iptc.py index 9f48633e1..800563af1 100644 --- a/Tests/test_file_iptc.py +++ b/Tests/test_file_iptc.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image, IptcImagePlugin +from .helper import PillowTestCase, hopper + TEST_FILE = "Tests/images/iptc.jpg" diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index 4ade11a29..e0cb7528e 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -1,13 +1,10 @@ -from .helper import unittest, PillowTestCase, hopper -from .helper import djpeg_available, cjpeg_available - -from io import BytesIO import os import sys +from io import BytesIO -from PIL import Image -from PIL import ImageFile -from PIL import JpegImagePlugin +from PIL import Image, ImageFile, JpegImagePlugin + +from .helper import PillowTestCase, cjpeg_available, djpeg_available, hopper, unittest codecs = dir(Image.core) diff --git a/Tests/test_file_jpeg2k.py b/Tests/test_file_jpeg2k.py index a2483fade..7643cfebf 100644 --- a/Tests/test_file_jpeg2k.py +++ b/Tests/test_file_jpeg2k.py @@ -1,7 +1,8 @@ -from .helper import PillowTestCase +from io import BytesIO from PIL import Image, Jpeg2KImagePlugin -from io import BytesIO + +from .helper import PillowTestCase codecs = dir(Image.core) diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index 1eadea03e..bc5003f5f 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -1,17 +1,17 @@ from __future__ import print_function -from .helper import PillowTestCase, hopper -from PIL import features -from PIL._util import py3 +import distutils.version +import io +import itertools +import logging +import os from collections import namedtuple from ctypes import c_float -import io -import logging -import itertools -import os -import distutils.version -from PIL import Image, TiffImagePlugin, TiffTags +from PIL import Image, TiffImagePlugin, TiffTags, features +from PIL._util import py3 + +from .helper import PillowTestCase, hopper logger = logging.getLogger(__name__) diff --git a/Tests/test_file_mcidas.py b/Tests/test_file_mcidas.py index 5b8f4d592..acc4ddb91 100644 --- a/Tests/test_file_mcidas.py +++ b/Tests/test_file_mcidas.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import Image, McIdasImagePlugin +from .helper import PillowTestCase + class TestFileMcIdas(PillowTestCase): def test_invalid_file(self): diff --git a/Tests/test_file_mic.py b/Tests/test_file_mic.py index 390f56af1..5ec110c80 100644 --- a/Tests/test_file_mic.py +++ b/Tests/test_file_mic.py @@ -1,7 +1,7 @@ -from .helper import unittest, PillowTestCase, hopper - from PIL import Image, ImagePalette, features +from .helper import PillowTestCase, hopper, unittest + try: from PIL import MicImagePlugin except ImportError: diff --git a/Tests/test_file_mpo.py b/Tests/test_file_mpo.py index 45f88ca61..82ecf6457 100644 --- a/Tests/test_file_mpo.py +++ b/Tests/test_file_mpo.py @@ -1,7 +1,8 @@ -from .helper import PillowTestCase from io import BytesIO + from PIL import Image +from .helper import PillowTestCase test_files = ["Tests/images/sugarshack.mpo", "Tests/images/frozenpond.mpo"] diff --git a/Tests/test_file_msp.py b/Tests/test_file_msp.py index c60138ebd..5d512047b 100644 --- a/Tests/test_file_msp.py +++ b/Tests/test_file_msp.py @@ -1,8 +1,8 @@ -from .helper import unittest, PillowTestCase, hopper +import os from PIL import Image, MspImagePlugin -import os +from .helper import PillowTestCase, hopper, unittest TEST_FILE = "Tests/images/hopper.msp" EXTRA_DIR = "Tests/images/picins" diff --git a/Tests/test_file_palm.py b/Tests/test_file_palm.py index f68b5a871..fbfd89661 100644 --- a/Tests/test_file_palm.py +++ b/Tests/test_file_palm.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper, imagemagick_available - import os.path +from .helper import PillowTestCase, hopper, imagemagick_available + class TestFilePalm(PillowTestCase): _roundtrip = imagemagick_available() diff --git a/Tests/test_file_pcd.py b/Tests/test_file_pcd.py index 1bd66783a..b23328ba5 100644 --- a/Tests/test_file_pcd.py +++ b/Tests/test_file_pcd.py @@ -1,6 +1,7 @@ -from .helper import PillowTestCase from PIL import Image +from .helper import PillowTestCase + class TestFilePcd(PillowTestCase): def test_load_raw(self): diff --git a/Tests/test_file_pcx.py b/Tests/test_file_pcx.py index ae8f0f2ee..eb2c7d611 100644 --- a/Tests/test_file_pcx.py +++ b/Tests/test_file_pcx.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image, ImageFile, PcxImagePlugin +from .helper import PillowTestCase, hopper + class TestFilePcx(PillowTestCase): def _roundtrip(self, im): diff --git a/Tests/test_file_pdf.py b/Tests/test_file_pdf.py index b7ee70034..25c2f6bf6 100644 --- a/Tests/test_file_pdf.py +++ b/Tests/test_file_pdf.py @@ -1,11 +1,13 @@ -from .helper import PillowTestCase, hopper -from PIL import Image, PdfParser import io import os import os.path import tempfile import time +from PIL import Image, PdfParser + +from .helper import PillowTestCase, hopper + class TestFilePdf(PillowTestCase): def helper_save_as_pdf(self, mode, **kwargs): diff --git a/Tests/test_file_pixar.py b/Tests/test_file_pixar.py index df5b22d75..c744932d4 100644 --- a/Tests/test_file_pixar.py +++ b/Tests/test_file_pixar.py @@ -1,7 +1,7 @@ -from .helper import hopper, PillowTestCase - from PIL import Image, PixarImagePlugin +from .helper import PillowTestCase, hopper + TEST_FILE = "Tests/images/hopper.pxr" diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 4824f122b..6d76a6caa 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -1,10 +1,11 @@ -from .helper import unittest, PillowTestCase, PillowLeakTestCase, hopper +import sys +import zlib +from io import BytesIO + from PIL import Image, ImageFile, PngImagePlugin from PIL._util import py3 -from io import BytesIO -import zlib -import sys +from .helper import PillowLeakTestCase, PillowTestCase, hopper, unittest try: from PIL import _webp diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py index 74406612f..5d2a0bc69 100644 --- a/Tests/test_file_ppm.py +++ b/Tests/test_file_ppm.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + # sample ppm stream test_file = "Tests/images/hopper.ppm" diff --git a/Tests/test_file_psd.py b/Tests/test_file_psd.py index 45fc0ef71..f55ee1dcb 100644 --- a/Tests/test_file_psd.py +++ b/Tests/test_file_psd.py @@ -1,7 +1,7 @@ -from .helper import hopper, PillowTestCase - from PIL import Image, PsdImagePlugin +from .helper import PillowTestCase, hopper + test_file = "Tests/images/hopper.psd" diff --git a/Tests/test_file_sgi.py b/Tests/test_file_sgi.py index bf0af5066..ff3aea1d5 100644 --- a/Tests/test_file_sgi.py +++ b/Tests/test_file_sgi.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image, SgiImagePlugin +from .helper import PillowTestCase, hopper + class TestFileSgi(PillowTestCase): def test_rgb(self): diff --git a/Tests/test_file_spider.py b/Tests/test_file_spider.py index 7dec15058..8a1eb6637 100644 --- a/Tests/test_file_spider.py +++ b/Tests/test_file_spider.py @@ -1,11 +1,9 @@ -from .helper import PillowTestCase, hopper - -from PIL import Image -from PIL import ImageSequence -from PIL import SpiderImagePlugin - import tempfile +from PIL import Image, ImageSequence, SpiderImagePlugin + +from .helper import PillowTestCase, hopper + TEST_FILE = "Tests/images/hopper.spider" diff --git a/Tests/test_file_sun.py b/Tests/test_file_sun.py index 7270665c3..84d59e0c7 100644 --- a/Tests/test_file_sun.py +++ b/Tests/test_file_sun.py @@ -1,8 +1,8 @@ -from .helper import unittest, PillowTestCase, hopper +import os from PIL import Image, SunImagePlugin -import os +from .helper import PillowTestCase, hopper, unittest EXTRA_DIR = "Tests/images/sunraster" diff --git a/Tests/test_file_tar.py b/Tests/test_file_tar.py index cd123e112..c4666a65a 100644 --- a/Tests/test_file_tar.py +++ b/Tests/test_file_tar.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import Image, TarIO +from .helper import PillowTestCase + codecs = dir(Image.core) # Sample tar archive diff --git a/Tests/test_file_tga.py b/Tests/test_file_tga.py index 6bc37f258..abbebe0eb 100644 --- a/Tests/test_file_tga.py +++ b/Tests/test_file_tga.py @@ -2,10 +2,9 @@ import os from glob import glob from itertools import product -from .helper import PillowTestCase - from PIL import Image +from .helper import PillowTestCase _TGA_DIR = os.path.join("Tests", "images", "tga") _TGA_DIR_COMMON = os.path.join(_TGA_DIR, "common") diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 3b0afba67..c3f55150c 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -1,12 +1,12 @@ import logging -from io import BytesIO import sys - -from .helper import unittest, PillowTestCase, hopper +from io import BytesIO from PIL import Image, TiffImagePlugin, features from PIL._util import py3 -from PIL.TiffImagePlugin import X_RESOLUTION, Y_RESOLUTION, RESOLUTION_UNIT +from PIL.TiffImagePlugin import RESOLUTION_UNIT, X_RESOLUTION, Y_RESOLUTION + +from .helper import PillowTestCase, hopper, unittest logger = logging.getLogger(__name__) diff --git a/Tests/test_file_tiff_metadata.py b/Tests/test_file_tiff_metadata.py index f9b197a56..8761e431e 100644 --- a/Tests/test_file_tiff_metadata.py +++ b/Tests/test_file_tiff_metadata.py @@ -1,10 +1,10 @@ import io import struct -from .helper import PillowTestCase, hopper - from PIL import Image, TiffImagePlugin, TiffTags -from PIL.TiffImagePlugin import _limit_rational, IFDRational +from PIL.TiffImagePlugin import IFDRational, _limit_rational + +from .helper import PillowTestCase, hopper tag_ids = {info.name: info.value for info in TiffTags.TAGS_V2.values()} diff --git a/Tests/test_file_wal.py b/Tests/test_file_wal.py index 8b85aaecd..74c238fc1 100644 --- a/Tests/test_file_wal.py +++ b/Tests/test_file_wal.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import WalImageFile +from .helper import PillowTestCase + class TestFileWal(PillowTestCase): def test_open(self): diff --git a/Tests/test_file_webp.py b/Tests/test_file_webp.py index 659f2baf1..4d44f47b6 100644 --- a/Tests/test_file_webp.py +++ b/Tests/test_file_webp.py @@ -1,7 +1,7 @@ -from .helper import unittest, PillowTestCase, hopper - from PIL import Image, WebPImagePlugin +from .helper import PillowTestCase, hopper, unittest + try: from PIL import _webp diff --git a/Tests/test_file_webp_alpha.py b/Tests/test_file_webp_alpha.py index 255fa6e22..f2f10d7b7 100644 --- a/Tests/test_file_webp_alpha.py +++ b/Tests/test_file_webp_alpha.py @@ -1,7 +1,7 @@ -from .helper import unittest, PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper, unittest + try: from PIL import _webp except ImportError: diff --git a/Tests/test_file_webp_animated.py b/Tests/test_file_webp_animated.py index 6a73fccdf..dec74d0d0 100644 --- a/Tests/test_file_webp_animated.py +++ b/Tests/test_file_webp_animated.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import Image +from .helper import PillowTestCase + try: from PIL import _webp diff --git a/Tests/test_file_webp_lossless.py b/Tests/test_file_webp_lossless.py index c9dddfcd4..2eff41529 100644 --- a/Tests/test_file_webp_lossless.py +++ b/Tests/test_file_webp_lossless.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + try: from PIL import _webp diff --git a/Tests/test_file_webp_metadata.py b/Tests/test_file_webp_metadata.py index 7f4b457ed..ae528e3bf 100644 --- a/Tests/test_file_webp_metadata.py +++ b/Tests/test_file_webp_metadata.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import Image +from .helper import PillowTestCase + try: from PIL import _webp diff --git a/Tests/test_file_wmf.py b/Tests/test_file_wmf.py index cf104cfe3..cea0cec5b 100644 --- a/Tests/test_file_wmf.py +++ b/Tests/test_file_wmf.py @@ -1,7 +1,6 @@ -from .helper import PillowTestCase, hopper +from PIL import Image, WmfImagePlugin -from PIL import Image -from PIL import WmfImagePlugin +from .helper import PillowTestCase, hopper class TestFileWmf(PillowTestCase): diff --git a/Tests/test_file_xbm.py b/Tests/test_file_xbm.py index 3ebadf030..9693ba05a 100644 --- a/Tests/test_file_xbm.py +++ b/Tests/test_file_xbm.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import Image +from .helper import PillowTestCase + PIL151 = b""" #define basic_width 32 #define basic_height 32 diff --git a/Tests/test_file_xpm.py b/Tests/test_file_xpm.py index 4133b0096..a49b7c8dd 100644 --- a/Tests/test_file_xpm.py +++ b/Tests/test_file_xpm.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image, XpmImagePlugin +from .helper import PillowTestCase, hopper + TEST_FILE = "Tests/images/hopper.xpm" diff --git a/Tests/test_file_xvthumb.py b/Tests/test_file_xvthumb.py index bcced2853..f8b6d3531 100644 --- a/Tests/test_file_xvthumb.py +++ b/Tests/test_file_xvthumb.py @@ -1,7 +1,7 @@ -from .helper import hopper, PillowTestCase - from PIL import Image, XVThumbImagePlugin +from .helper import PillowTestCase, hopper + TEST_FILE = "Tests/images/hopper.p7" diff --git a/Tests/test_font_bdf.py b/Tests/test_font_bdf.py index 69badc376..9b3a342d0 100644 --- a/Tests/test_font_bdf.py +++ b/Tests/test_font_bdf.py @@ -1,6 +1,6 @@ -from .helper import PillowTestCase +from PIL import BdfFontFile, FontFile -from PIL import FontFile, BdfFontFile +from .helper import PillowTestCase filename = "Tests/images/courB08.bdf" diff --git a/Tests/test_font_leaks.py b/Tests/test_font_leaks.py index 84f2a434f..14b368585 100644 --- a/Tests/test_font_leaks.py +++ b/Tests/test_font_leaks.py @@ -1,7 +1,10 @@ from __future__ import division -from .helper import unittest, PillowLeakTestCase + import sys -from PIL import Image, features, ImageDraw, ImageFont + +from PIL import Image, ImageDraw, ImageFont, features + +from .helper import PillowLeakTestCase, unittest @unittest.skipIf(sys.platform.startswith("win32"), "requires Unix or macOS") diff --git a/Tests/test_font_pcf.py b/Tests/test_font_pcf.py index 5db389d37..a2b4ef27e 100644 --- a/Tests/test_font_pcf.py +++ b/Tests/test_font_pcf.py @@ -1,9 +1,8 @@ -from .helper import PillowTestCase - -from PIL import Image, FontFile, PcfFontFile -from PIL import ImageFont, ImageDraw +from PIL import FontFile, Image, ImageDraw, ImageFont, PcfFontFile from PIL._util import py3 +from .helper import PillowTestCase + codecs = dir(Image.core) fontname = "Tests/fonts/10x20-ISO8859-1.pcf" diff --git a/Tests/test_format_hsv.py b/Tests/test_format_hsv.py index 781bfc801..ce0524e1e 100644 --- a/Tests/test_format_hsv.py +++ b/Tests/test_format_hsv.py @@ -1,10 +1,10 @@ -from .helper import PillowTestCase, hopper +import colorsys +import itertools from PIL import Image from PIL._util import py3 -import colorsys -import itertools +from .helper import PillowTestCase, hopper class TestFormatHSV(PillowTestCase): diff --git a/Tests/test_format_lab.py b/Tests/test_format_lab.py index 87e985832..a98c20579 100644 --- a/Tests/test_format_lab.py +++ b/Tests/test_format_lab.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import Image +from .helper import PillowTestCase + class TestFormatLab(PillowTestCase): def test_white(self): diff --git a/Tests/test_image.py b/Tests/test_image.py index 5afbbcc3c..493b4735a 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -1,10 +1,11 @@ -from .helper import unittest, PillowTestCase, hopper +import os +import shutil +import sys from PIL import Image from PIL._util import py3 -import os -import sys -import shutil + +from .helper import PillowTestCase, hopper, unittest class TestImage(PillowTestCase): diff --git a/Tests/test_image_access.py b/Tests/test_image_access.py index e0d0b6136..b06814cb9 100644 --- a/Tests/test_image_access.py +++ b/Tests/test_image_access.py @@ -1,8 +1,9 @@ -from .helper import unittest, PillowTestCase, hopper, on_appveyor +import os +import sys from PIL import Image -import sys -import os + +from .helper import PillowTestCase, hopper, on_appveyor, unittest # CFFI imports pycparser which doesn't support PYTHONOPTIMIZE=2 # https://github.com/eliben/pycparser/pull/198#issuecomment-317001670 diff --git a/Tests/test_image_array.py b/Tests/test_image_array.py index 05d20fca2..02e5c80f2 100644 --- a/Tests/test_image_array.py +++ b/Tests/test_image_array.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + im = hopper().resize((128, 100)) diff --git a/Tests/test_image_convert.py b/Tests/test_image_convert.py index bd01417c5..96ecf8996 100644 --- a/Tests/test_image_convert.py +++ b/Tests/test_image_convert.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + class TestImageConvert(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_image_copy.py b/Tests/test_image_copy.py index eb590a6d6..653159e14 100644 --- a/Tests/test_image_copy.py +++ b/Tests/test_image_copy.py @@ -1,8 +1,8 @@ -from .helper import PillowTestCase, hopper +import copy from PIL import Image -import copy +from .helper import PillowTestCase, hopper class TestImageCopy(PillowTestCase): diff --git a/Tests/test_image_crop.py b/Tests/test_image_crop.py index 751356aad..6a604f494 100644 --- a/Tests/test_image_crop.py +++ b/Tests/test_image_crop.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + class TestImageCrop(PillowTestCase): def test_crop(self): diff --git a/Tests/test_image_draft.py b/Tests/test_image_draft.py index 5fd6bd0fd..5d92ee797 100644 --- a/Tests/test_image_draft.py +++ b/Tests/test_image_draft.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, fromstring, tostring - from PIL import Image +from .helper import PillowTestCase, fromstring, tostring + class TestImageDraft(PillowTestCase): def setUp(self): diff --git a/Tests/test_image_filter.py b/Tests/test_image_filter.py index 7558aef36..bbd10e6e5 100644 --- a/Tests/test_image_filter.py +++ b/Tests/test_image_filter.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image, ImageFilter +from .helper import PillowTestCase, hopper + class TestImageFilter(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_image_frombytes.py b/Tests/test_image_frombytes.py index fe7201f13..21d466d02 100644 --- a/Tests/test_image_frombytes.py +++ b/Tests/test_image_frombytes.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + class TestImageFromBytes(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_image_fromqimage.py b/Tests/test_image_fromqimage.py index c91b8dd93..d7556a680 100644 --- a/Tests/test_image_fromqimage.py +++ b/Tests/test_image_fromqimage.py @@ -1,8 +1,8 @@ +from PIL import Image, ImageQt + from .helper import PillowTestCase, hopper from .test_imageqt import PillowQtTestCase -from PIL import ImageQt, Image - class TestFromQImage(PillowQtTestCase, PillowTestCase): diff --git a/Tests/test_image_getbands.py b/Tests/test_image_getbands.py index 4d3a9f86b..785b2ae42 100644 --- a/Tests/test_image_getbands.py +++ b/Tests/test_image_getbands.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import Image +from .helper import PillowTestCase + class TestImageGetBands(PillowTestCase): def test_getbands(self): diff --git a/Tests/test_image_getbbox.py b/Tests/test_image_getbbox.py index 5b0905fef..2df9f20f1 100644 --- a/Tests/test_image_getbbox.py +++ b/Tests/test_image_getbbox.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + class TestImageGetBbox(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_image_getextrema.py b/Tests/test_image_getextrema.py index 5d3fe2642..1944b041c 100644 --- a/Tests/test_image_getextrema.py +++ b/Tests/test_image_getextrema.py @@ -1,4 +1,5 @@ from PIL import Image + from .helper import PillowTestCase, hopper diff --git a/Tests/test_image_getim.py b/Tests/test_image_getim.py index a5eefad2e..3f0c46c46 100644 --- a/Tests/test_image_getim.py +++ b/Tests/test_image_getim.py @@ -1,6 +1,7 @@ -from .helper import PillowTestCase, hopper from PIL._util import py3 +from .helper import PillowTestCase, hopper + class TestImageGetIm(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_image_getprojection.py b/Tests/test_image_getprojection.py index bdd70bb7e..3b8bca64f 100644 --- a/Tests/test_image_getprojection.py +++ b/Tests/test_image_getprojection.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + class TestImageGetProjection(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_image_load.py b/Tests/test_image_load.py index c984e506f..2770126c4 100644 --- a/Tests/test_image_load.py +++ b/Tests/test_image_load.py @@ -1,8 +1,8 @@ -from .helper import PillowTestCase, hopper +import os from PIL import Image -import os +from .helper import PillowTestCase, hopper class TestImageLoad(PillowTestCase): diff --git a/Tests/test_image_mode.py b/Tests/test_image_mode.py index e41a20e9b..e23957916 100644 --- a/Tests/test_image_mode.py +++ b/Tests/test_image_mode.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + class TestImageMode(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_image_paste.py b/Tests/test_image_paste.py index a9ec682e4..3139db664 100644 --- a/Tests/test_image_paste.py +++ b/Tests/test_image_paste.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, cached_property - from PIL import Image +from .helper import PillowTestCase, cached_property + class TestImagingPaste(PillowTestCase): masks = {} diff --git a/Tests/test_image_putalpha.py b/Tests/test_image_putalpha.py index 859c39115..6dc802598 100644 --- a/Tests/test_image_putalpha.py +++ b/Tests/test_image_putalpha.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import Image +from .helper import PillowTestCase + class TestImagePutAlpha(PillowTestCase): def test_interface(self): diff --git a/Tests/test_image_putdata.py b/Tests/test_image_putdata.py index 3d309eef2..a213fbf88 100644 --- a/Tests/test_image_putdata.py +++ b/Tests/test_image_putdata.py @@ -1,10 +1,10 @@ -from .helper import PillowTestCase, hopper +import sys from array import array -import sys - from PIL import Image +from .helper import PillowTestCase, hopper + class TestImagePutData(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_image_putpalette.py b/Tests/test_image_putpalette.py index 55fa71fa5..68cfc4efe 100644 --- a/Tests/test_image_putpalette.py +++ b/Tests/test_image_putpalette.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import ImagePalette +from .helper import PillowTestCase, hopper + class TestImagePutPalette(PillowTestCase): def test_putpalette(self): diff --git a/Tests/test_image_quantize.py b/Tests/test_image_quantize.py index 0c56609e2..2be5b74fc 100644 --- a/Tests/test_image_quantize.py +++ b/Tests/test_image_quantize.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + class TestImageQuantize(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_image_resample.py b/Tests/test_image_resample.py index 8f666b573..7d1dc009d 100644 --- a/Tests/test_image_resample.py +++ b/Tests/test_image_resample.py @@ -2,9 +2,10 @@ from __future__ import division, print_function from contextlib import contextmanager -from .helper import unittest, PillowTestCase, hopper from PIL import Image, ImageDraw +from .helper import PillowTestCase, hopper, unittest + class TestImagingResampleVulnerability(PillowTestCase): # see https://github.com/python-pillow/Pillow/issues/1710 diff --git a/Tests/test_image_resize.py b/Tests/test_image_resize.py index aa831faa8..7c35be570 100644 --- a/Tests/test_image_resize.py +++ b/Tests/test_image_resize.py @@ -3,10 +3,10 @@ Tests for resize functionality. """ from itertools import permutations -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + class TestImagingCoreResize(PillowTestCase): def resize(self, im, size, f): diff --git a/Tests/test_image_rotate.py b/Tests/test_image_rotate.py index a2363b6bc..9c62e7362 100644 --- a/Tests/test_image_rotate.py +++ b/Tests/test_image_rotate.py @@ -1,6 +1,7 @@ -from .helper import PillowTestCase, hopper from PIL import Image +from .helper import PillowTestCase, hopper + class TestImageRotate(PillowTestCase): def rotate(self, im, mode, angle, center=None, translate=None): diff --git a/Tests/test_image_split.py b/Tests/test_image_split.py index e1bc17be2..a19878aae 100644 --- a/Tests/test_image_split.py +++ b/Tests/test_image_split.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + class TestImageSplit(PillowTestCase): def test_split(self): diff --git a/Tests/test_image_thumbnail.py b/Tests/test_image_thumbnail.py index a53f31461..bd7c98c28 100644 --- a/Tests/test_image_thumbnail.py +++ b/Tests/test_image_thumbnail.py @@ -1,6 +1,7 @@ -from .helper import PillowTestCase, hopper from PIL import Image +from .helper import PillowTestCase, hopper + class TestImageThumbnail(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_image_tobitmap.py b/Tests/test_image_tobitmap.py index 8af565f5e..d7c879a25 100644 --- a/Tests/test_image_tobitmap.py +++ b/Tests/test_image_tobitmap.py @@ -1,4 +1,4 @@ -from .helper import PillowTestCase, hopper, fromstring +from .helper import PillowTestCase, fromstring, hopper class TestImageToBitmap(PillowTestCase): diff --git a/Tests/test_image_transform.py b/Tests/test_image_transform.py index feedf366e..a0e54176a 100644 --- a/Tests/test_image_transform.py +++ b/Tests/test_image_transform.py @@ -1,9 +1,9 @@ import math -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + class TestImageTransform(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_image_transpose.py b/Tests/test_image_transpose.py index 021e174f2..f5e8746ee 100644 --- a/Tests/test_image_transpose.py +++ b/Tests/test_image_transpose.py @@ -1,6 +1,3 @@ -from . import helper -from .helper import PillowTestCase - from PIL.Image import ( FLIP_LEFT_RIGHT, FLIP_TOP_BOTTOM, @@ -11,6 +8,9 @@ from PIL.Image import ( TRANSVERSE, ) +from . import helper +from .helper import PillowTestCase + class TestImageTranspose(PillowTestCase): diff --git a/Tests/test_imagechops.py b/Tests/test_imagechops.py index 76ca397df..6f42a28df 100644 --- a/Tests/test_imagechops.py +++ b/Tests/test_imagechops.py @@ -1,7 +1,6 @@ -from .helper import PillowTestCase, hopper +from PIL import Image, ImageChops -from PIL import Image -from PIL import ImageChops +from .helper import PillowTestCase, hopper BLACK = (0, 0, 0) BROWN = (127, 64, 0) diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py index 678af4494..10465e739 100644 --- a/Tests/test_imagecms.py +++ b/Tests/test_imagecms.py @@ -1,10 +1,10 @@ -from .helper import PillowTestCase, hopper import datetime +import os +from io import BytesIO from PIL import Image, ImageMode -from io import BytesIO -import os +from .helper import PillowTestCase, hopper try: from PIL import ImageCms diff --git a/Tests/test_imagecolor.py b/Tests/test_imagecolor.py index c0983ec4c..e4a7b7dfe 100644 --- a/Tests/test_imagecolor.py +++ b/Tests/test_imagecolor.py @@ -1,7 +1,6 @@ -from .helper import PillowTestCase +from PIL import Image, ImageColor -from PIL import Image -from PIL import ImageColor +from .helper import PillowTestCase class TestImageColor(PillowTestCase): diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index 753b98681..ffe35a4fa 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -1,8 +1,9 @@ import os.path -from .helper import PillowTestCase, hopper from PIL import Image, ImageColor, ImageDraw +from .helper import PillowTestCase, hopper + BLACK = (0, 0, 0) WHITE = (255, 255, 255) GRAY = (190, 190, 190) diff --git a/Tests/test_imagedraw2.py b/Tests/test_imagedraw2.py index 5e75a08f7..9ce472dd0 100644 --- a/Tests/test_imagedraw2.py +++ b/Tests/test_imagedraw2.py @@ -1,8 +1,9 @@ import os.path -from .helper import PillowTestCase, hopper, unittest from PIL import Image, ImageDraw2, features +from .helper import PillowTestCase, hopper, unittest + BLACK = (0, 0, 0) WHITE = (255, 255, 255) GRAY = (190, 190, 190) diff --git a/Tests/test_imageenhance.py b/Tests/test_imageenhance.py index 4f7c90559..b2235853a 100644 --- a/Tests/test_imageenhance.py +++ b/Tests/test_imageenhance.py @@ -1,7 +1,6 @@ -from .helper import PillowTestCase, hopper +from PIL import Image, ImageEnhance -from PIL import Image -from PIL import ImageEnhance +from .helper import PillowTestCase, hopper class TestImageEnhance(PillowTestCase): diff --git a/Tests/test_imagefile.py b/Tests/test_imagefile.py index 83170cb2a..2ca5abe4c 100644 --- a/Tests/test_imagefile.py +++ b/Tests/test_imagefile.py @@ -1,10 +1,8 @@ -from .helper import unittest, PillowTestCase, hopper, fromstring, tostring - from io import BytesIO -from PIL import Image -from PIL import ImageFile -from PIL import EpsImagePlugin +from PIL import EpsImagePlugin, Image, ImageFile + +from .helper import PillowTestCase, fromstring, hopper, tostring, unittest try: from PIL import _webp diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index ace3b7d33..21b71fcbb 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -1,14 +1,15 @@ # -*- coding: utf-8 -*- -from .helper import unittest, PillowTestCase - -from PIL import Image, ImageDraw, ImageFont, features -from io import BytesIO -import os -import sys import copy +import distutils.version +import os import re import shutil -import distutils.version +import sys +from io import BytesIO + +from PIL import Image, ImageDraw, ImageFont, features + +from .helper import PillowTestCase, unittest FONT_PATH = "Tests/fonts/FreeMono.ttf" FONT_SIZE = 20 diff --git a/Tests/test_imagefont_bitmap.py b/Tests/test_imagefont_bitmap.py index 5a8ee2e08..b7be8f723 100644 --- a/Tests/test_imagefont_bitmap.py +++ b/Tests/test_imagefont_bitmap.py @@ -1,6 +1,6 @@ -from .helper import unittest, PillowTestCase -from PIL import Image, ImageFont, ImageDraw +from PIL import Image, ImageDraw, ImageFont +from .helper import PillowTestCase, unittest image_font_installed = True try: diff --git a/Tests/test_imagefontctl.py b/Tests/test_imagefontctl.py index 3ec5e9055..afd45ce19 100644 --- a/Tests/test_imagefontctl.py +++ b/Tests/test_imagefontctl.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from .helper import unittest, PillowTestCase from PIL import Image, ImageDraw, ImageFont, features +from .helper import PillowTestCase, unittest FONT_SIZE = 20 FONT_PATH = "Tests/fonts/DejaVuSans.ttf" diff --git a/Tests/test_imagegrab.py b/Tests/test_imagegrab.py index 9ead827e0..a29bc019e 100644 --- a/Tests/test_imagegrab.py +++ b/Tests/test_imagegrab.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - -import sys import subprocess +import sys + +from .helper import PillowTestCase try: from PIL import ImageGrab diff --git a/Tests/test_imagemath.py b/Tests/test_imagemath.py index a1a9bad0f..da41b3a12 100644 --- a/Tests/test_imagemath.py +++ b/Tests/test_imagemath.py @@ -1,8 +1,8 @@ from __future__ import print_function -from .helper import PillowTestCase -from PIL import Image -from PIL import ImageMath +from PIL import Image, ImageMath + +from .helper import PillowTestCase def pixel(im): diff --git a/Tests/test_imagemorph.py b/Tests/test_imagemorph.py index 8ecd170e8..1492872b6 100644 --- a/Tests/test_imagemorph.py +++ b/Tests/test_imagemorph.py @@ -1,8 +1,8 @@ # Test the ImageMorphology functionality -from .helper import PillowTestCase, hopper - from PIL import Image, ImageMorph, _imagingmorph +from .helper import PillowTestCase, hopper + class MorphTests(PillowTestCase): def setUp(self): diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py index 006af903e..85529a708 100644 --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -1,7 +1,6 @@ -from .helper import PillowTestCase, hopper +from PIL import Image, ImageOps -from PIL import Image -from PIL import ImageOps +from .helper import PillowTestCase, hopper try: from PIL import _webp diff --git a/Tests/test_imageops_usm.py b/Tests/test_imageops_usm.py index fc49f4d2d..8340c5f0d 100644 --- a/Tests/test_imageops_usm.py +++ b/Tests/test_imageops_usm.py @@ -1,7 +1,6 @@ -from .helper import PillowTestCase +from PIL import Image, ImageFilter -from PIL import Image -from PIL import ImageFilter +from .helper import PillowTestCase im = Image.open("Tests/images/hopper.ppm") snakes = Image.open("Tests/images/color_snakes.png") diff --git a/Tests/test_imagepalette.py b/Tests/test_imagepalette.py index 50670f26c..1297712ef 100644 --- a/Tests/test_imagepalette.py +++ b/Tests/test_imagepalette.py @@ -1,6 +1,6 @@ -from .helper import PillowTestCase +from PIL import Image, ImagePalette -from PIL import ImagePalette, Image +from .helper import PillowTestCase class TestImagePalette(PillowTestCase): diff --git a/Tests/test_imagepath.py b/Tests/test_imagepath.py index f5309ee14..ed65d47c1 100644 --- a/Tests/test_imagepath.py +++ b/Tests/test_imagepath.py @@ -1,11 +1,11 @@ -from .helper import PillowTestCase - -from PIL import ImagePath, Image -from PIL._util import py3 - import array import struct +from PIL import Image, ImagePath +from PIL._util import py3 + +from .helper import PillowTestCase + class TestImagePath(PillowTestCase): def test_path(self): diff --git a/Tests/test_imageqt.py b/Tests/test_imageqt.py index 696acdb85..dc43e6bc7 100644 --- a/Tests/test_imageqt.py +++ b/Tests/test_imageqt.py @@ -1,16 +1,12 @@ -from .helper import PillowTestCase, hopper - +import sys import warnings -deprecated = False -with warnings.catch_warnings(): - warnings.filterwarnings("error", category=DeprecationWarning) - try: - from PIL import ImageQt - except DeprecationWarning: - deprecated = True - warnings.filterwarnings("ignore", category=DeprecationWarning) - from PIL import ImageQt +from PIL import ImageQt + +from .helper import PillowTestCase, hopper + +if sys.version_info.major >= 3: + from importlib import reload if ImageQt.qt_is_installed: from PIL.ImageQt import qRgba @@ -89,4 +85,11 @@ class TestImageQt(PillowQtTestCase, PillowTestCase): ImageQt.ImageQt(hopper(mode)) def test_deprecated(self): - self.assertEqual(ImageQt.qt_version in ["4", "side"], deprecated) + with warnings.catch_warnings(record=True) as w: + reload(ImageQt) + if ImageQt.qt_version in ["4", "side"]: + self.assertEqual(len(w), 1) + self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) + else: + # No warning. + self.assertEqual(w, []) diff --git a/Tests/test_imagesequence.py b/Tests/test_imagesequence.py index 5d90dc4c5..1eea839da 100644 --- a/Tests/test_imagesequence.py +++ b/Tests/test_imagesequence.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image, ImageSequence, TiffImagePlugin +from .helper import PillowTestCase, hopper + class TestImageSequence(PillowTestCase): def test_sanity(self): diff --git a/Tests/test_imageshow.py b/Tests/test_imageshow.py index a77acd307..378afe2db 100644 --- a/Tests/test_imageshow.py +++ b/Tests/test_imageshow.py @@ -1,7 +1,6 @@ -from .helper import PillowTestCase, hopper +from PIL import Image, ImageShow -from PIL import Image -from PIL import ImageShow +from .helper import PillowTestCase, hopper class TestImageShow(PillowTestCase): diff --git a/Tests/test_imagestat.py b/Tests/test_imagestat.py index ef0f28c32..d6c6a7a55 100644 --- a/Tests/test_imagestat.py +++ b/Tests/test_imagestat.py @@ -1,7 +1,6 @@ -from .helper import PillowTestCase, hopper +from PIL import Image, ImageStat -from PIL import Image -from PIL import ImageStat +from .helper import PillowTestCase, hopper class TestImageStat(PillowTestCase): diff --git a/Tests/test_imagetk.py b/Tests/test_imagetk.py index 9bcb4954a..c397c84be 100644 --- a/Tests/test_imagetk.py +++ b/Tests/test_imagetk.py @@ -1,7 +1,7 @@ -from .helper import unittest, PillowTestCase, hopper from PIL import Image from PIL._util import py3 +from .helper import PillowTestCase, hopper, unittest try: from PIL import ImageTk diff --git a/Tests/test_imagewin.py b/Tests/test_imagewin.py index 82f11a68d..92fcdc28d 100644 --- a/Tests/test_imagewin.py +++ b/Tests/test_imagewin.py @@ -1,7 +1,8 @@ -from .helper import unittest, PillowTestCase, hopper +import sys from PIL import ImageWin -import sys + +from .helper import PillowTestCase, hopper, unittest class TestImageWin(PillowTestCase): diff --git a/Tests/test_imagewin_pointers.py b/Tests/test_imagewin_pointers.py index 9c5704dbe..efa3753b9 100644 --- a/Tests/test_imagewin_pointers.py +++ b/Tests/test_imagewin_pointers.py @@ -1,9 +1,10 @@ -from .helper import PillowTestCase, hopper +import ctypes +import sys +from io import BytesIO + from PIL import Image, ImageWin -import sys -import ctypes -from io import BytesIO +from .helper import PillowTestCase, hopper # see https://github.com/python-pillow/Pillow/pull/1431#issuecomment-144692652 diff --git a/Tests/test_lib_image.py b/Tests/test_lib_image.py index 36a1e97af..68e72bc4e 100644 --- a/Tests/test_lib_image.py +++ b/Tests/test_lib_image.py @@ -1,7 +1,7 @@ -from .helper import unittest, PillowTestCase - from PIL import Image +from .helper import PillowTestCase, unittest + class TestLibImage(PillowTestCase): def test_setmode(self): diff --git a/Tests/test_lib_pack.py b/Tests/test_lib_pack.py index 88ba3a307..6178184bc 100644 --- a/Tests/test_lib_pack.py +++ b/Tests/test_lib_pack.py @@ -1,9 +1,8 @@ import sys -from .helper import PillowTestCase - from PIL import Image +from .helper import PillowTestCase X = 255 diff --git a/Tests/test_locale.py b/Tests/test_locale.py index 8836e4f5f..86229dbcb 100644 --- a/Tests/test_locale.py +++ b/Tests/test_locale.py @@ -1,9 +1,10 @@ from __future__ import print_function -from .helper import unittest, PillowTestCase + +import locale from PIL import Image -import locale +from .helper import PillowTestCase, unittest # ref https://github.com/python-pillow/Pillow/issues/272 # on windows, in polish locale: diff --git a/Tests/test_map.py b/Tests/test_map.py index 33920f118..653ed31e2 100644 --- a/Tests/test_map.py +++ b/Tests/test_map.py @@ -1,8 +1,9 @@ -from .helper import PillowTestCase, unittest import sys from PIL import Image +from .helper import PillowTestCase, unittest + @unittest.skipIf(sys.platform.startswith("win32"), "Win32 does not call map_buffer") class TestMap(PillowTestCase): diff --git a/Tests/test_mode_i16.py b/Tests/test_mode_i16.py index 27ca03ce5..b1cf2a233 100644 --- a/Tests/test_mode_i16.py +++ b/Tests/test_mode_i16.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase, hopper - from PIL import Image +from .helper import PillowTestCase, hopper + class TestModeI16(PillowTestCase): diff --git a/Tests/test_numpy.py b/Tests/test_numpy.py index d171e8c9b..872ecdbb6 100644 --- a/Tests/test_numpy.py +++ b/Tests/test_numpy.py @@ -1,8 +1,9 @@ from __future__ import print_function -from .helper import PillowTestCase, hopper, unittest from PIL import Image +from .helper import PillowTestCase, hopper, unittest + try: import numpy except ImportError: diff --git a/Tests/test_pdfparser.py b/Tests/test_pdfparser.py index 0de864ed8..0d4923480 100644 --- a/Tests/test_pdfparser.py +++ b/Tests/test_pdfparser.py @@ -1,4 +1,4 @@ -from .helper import PillowTestCase +import time from PIL.PdfParser import ( IndirectObjectDef, @@ -13,7 +13,8 @@ from PIL.PdfParser import ( encode_text, pdf_repr, ) -import time + +from .helper import PillowTestCase class TestPdfParser(PillowTestCase): diff --git a/Tests/test_pickle.py b/Tests/test_pickle.py index 710f2a1bd..42f47f169 100644 --- a/Tests/test_pickle.py +++ b/Tests/test_pickle.py @@ -1,7 +1,7 @@ -from .helper import PillowTestCase - from PIL import Image +from .helper import PillowTestCase + class TestPickle(PillowTestCase): def helper_pickle_file(self, pickle, protocol=0, mode=None): diff --git a/Tests/test_psdraw.py b/Tests/test_psdraw.py index 319f9b789..561df4ee6 100644 --- a/Tests/test_psdraw.py +++ b/Tests/test_psdraw.py @@ -1,9 +1,10 @@ -from .helper import PillowTestCase - -from PIL import Image, PSDraw import os import sys +from PIL import Image, PSDraw + +from .helper import PillowTestCase + class TestPsDraw(PillowTestCase): def _create_document(self, ps): diff --git a/Tests/test_pyroma.py b/Tests/test_pyroma.py index 69cf25b45..3455a502b 100644 --- a/Tests/test_pyroma.py +++ b/Tests/test_pyroma.py @@ -1,7 +1,7 @@ -from .helper import unittest, PillowTestCase - from PIL import __version__ +from .helper import PillowTestCase, unittest + try: import pyroma except ImportError: diff --git a/Tests/test_qt_image_fromqpixmap.py b/Tests/test_qt_image_fromqpixmap.py index 2bd448c61..1cff26d88 100644 --- a/Tests/test_qt_image_fromqpixmap.py +++ b/Tests/test_qt_image_fromqpixmap.py @@ -1,8 +1,8 @@ +from PIL import ImageQt + from .helper import PillowTestCase, hopper from .test_imageqt import PillowQPixmapTestCase -from PIL import ImageQt - class TestFromQPixmap(PillowQPixmapTestCase, PillowTestCase): def roundtrip(self, expected): diff --git a/Tests/test_qt_image_toqimage.py b/Tests/test_qt_image_toqimage.py index ec2f032a3..d0c223b1a 100644 --- a/Tests/test_qt_image_toqimage.py +++ b/Tests/test_qt_image_toqimage.py @@ -1,9 +1,8 @@ +from PIL import Image, ImageQt + from .helper import PillowTestCase, hopper from .test_imageqt import PillowQtTestCase -from PIL import ImageQt, Image - - if ImageQt.qt_is_installed: from PIL.ImageQt import QImage diff --git a/Tests/test_qt_image_toqpixmap.py b/Tests/test_qt_image_toqpixmap.py index 11dfab861..2c07f1bf5 100644 --- a/Tests/test_qt_image_toqpixmap.py +++ b/Tests/test_qt_image_toqpixmap.py @@ -1,8 +1,8 @@ +from PIL import ImageQt + from .helper import PillowTestCase, hopper from .test_imageqt import PillowQPixmapTestCase -from PIL import ImageQt - if ImageQt.qt_is_installed: from PIL.ImageQt import QPixmap diff --git a/Tests/test_shell_injection.py b/Tests/test_shell_injection.py index 83c003fc9..35a3dcfcd 100644 --- a/Tests/test_shell_injection.py +++ b/Tests/test_shell_injection.py @@ -1,10 +1,15 @@ -from .helper import unittest, PillowTestCase -from .helper import djpeg_available, cjpeg_available, netpbm_available - -import sys import shutil +import sys -from PIL import Image, JpegImagePlugin, GifImagePlugin +from PIL import GifImagePlugin, Image, JpegImagePlugin + +from .helper import ( + PillowTestCase, + cjpeg_available, + djpeg_available, + netpbm_available, + unittest, +) TEST_JPG = "Tests/images/hopper.jpg" TEST_GIF = "Tests/images/hopper.gif" diff --git a/Tests/test_tiff_ifdrational.py b/Tests/test_tiff_ifdrational.py index 66da8b3f6..f210c8737 100644 --- a/Tests/test_tiff_ifdrational.py +++ b/Tests/test_tiff_ifdrational.py @@ -1,9 +1,9 @@ -from .helper import PillowTestCase, hopper +from fractions import Fraction -from PIL import TiffImagePlugin, Image +from PIL import Image, TiffImagePlugin from PIL.TiffImagePlugin import IFDRational -from fractions import Fraction +from .helper import PillowTestCase, hopper class Test_IFDRational(PillowTestCase): diff --git a/Tests/test_util.py b/Tests/test_util.py index 593922f8c..5ec21a77c 100644 --- a/Tests/test_util.py +++ b/Tests/test_util.py @@ -1,7 +1,7 @@ -from .helper import unittest, PillowTestCase - from PIL import _util +from .helper import PillowTestCase, unittest + class TestUtil(PillowTestCase): def test_is_string_type(self): diff --git a/Tests/test_webp_leaks.py b/Tests/test_webp_leaks.py index 67586ba3a..93a6c2db0 100644 --- a/Tests/test_webp_leaks.py +++ b/Tests/test_webp_leaks.py @@ -1,7 +1,9 @@ -from .helper import unittest, PillowLeakTestCase -from PIL import Image, features from io import BytesIO +from PIL import Image, features + +from .helper import PillowLeakTestCase, unittest + test_file = "Tests/images/hopper.webp" diff --git a/Tests/threaded_save.py b/Tests/threaded_save.py index d8faffa0c..11eb86779 100644 --- a/Tests/threaded_save.py +++ b/Tests/threaded_save.py @@ -1,5 +1,4 @@ from __future__ import print_function -from PIL import Image import io import queue @@ -7,6 +6,8 @@ import sys import threading import time +from PIL import Image + test_format = sys.argv[1] if len(sys.argv) > 1 else "PNG" im = Image.open("Tests/images/hopper.ppm") diff --git a/Tests/versions.py b/Tests/versions.py index 835865b37..1ac226c9d 100644 --- a/Tests/versions.py +++ b/Tests/versions.py @@ -1,4 +1,5 @@ from __future__ import print_function + from PIL import Image diff --git a/docs/Guardfile b/docs/Guardfile index f8f3051ed..9b65e0379 100755 --- a/docs/Guardfile +++ b/docs/Guardfile @@ -1,6 +1,6 @@ #!/usr/bin/env python -from livereload.task import Task from livereload.compiler import shell +from livereload.task import Task Task.add('*.rst', shell('make html')) Task.add('*/*.rst', shell('make html')) diff --git a/docs/conf.py b/docs/conf.py index 0eb137daa..7347489f0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,9 +17,8 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # sys.path.insert(0, os.path.abspath('.')) -import sphinx_rtd_theme - import PIL +import sphinx_rtd_theme # -- General configuration ------------------------------------------------ diff --git a/docs/example/DdsImagePlugin.py b/docs/example/DdsImagePlugin.py index c171bb1f1..be493a316 100644 --- a/docs/example/DdsImagePlugin.py +++ b/docs/example/DdsImagePlugin.py @@ -12,8 +12,8 @@ Full text of the CC0 license: import struct from io import BytesIO -from PIL import Image, ImageFile +from PIL import Image, ImageFile # Magic ("DDS ") DDS_MAGIC = 0x20534444 diff --git a/mp_compile.py b/mp_compile.py index 04bfc3c9c..ec73e927e 100644 --- a/mp_compile.py +++ b/mp_compile.py @@ -4,10 +4,11 @@ # own newly-added support for parallel builds. from __future__ import print_function -from multiprocessing import Pool, cpu_count -from distutils.ccompiler import CCompiler + import os import sys +from distutils.ccompiler import CCompiler +from multiprocessing import Pool, cpu_count try: MAX_PROCS = int(os.environ.get("MAX_CONCURRENCY", min(4, cpu_count()))) diff --git a/selftest.py b/selftest.py index 4dea3363c..dcac54a5a 100755 --- a/selftest.py +++ b/selftest.py @@ -2,11 +2,10 @@ # minimal sanity check from __future__ import print_function -import sys import os +import sys -from PIL import Image -from PIL import features +from PIL import Image, features try: Image.core.ping diff --git a/setup.cfg b/setup.cfg index f55102a91..1c6ebc84c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,5 +5,11 @@ test=pytest extend-ignore = E203, W503 max-line-length = 88 +[isort] +combine_as_imports = True +include_trailing_comma = True +line_length = 88 +multi_line_output = 3 + [tool:pytest] addopts = -rs diff --git a/setup.py b/setup.py index 76b7b0819..c84b0fc8d 100755 --- a/setup.py +++ b/setup.py @@ -24,7 +24,6 @@ from setuptools import Extension, setup # comment this out to disable multi threaded builds. import mp_compile - if sys.platform == "win32" and sys.version_info >= (3, 8): warnings.warn( "Pillow does not yet support Python {}.{} and does not yet provide " diff --git a/src/PIL/BdfFontFile.py b/src/PIL/BdfFontFile.py index 9d43bbefa..fdf2c097e 100644 --- a/src/PIL/BdfFontFile.py +++ b/src/PIL/BdfFontFile.py @@ -19,8 +19,7 @@ from __future__ import print_function -from . import Image, FontFile - +from . import FontFile, Image # -------------------------------------------------------------------- # parse X Bitmap Distribution Format (BDF) diff --git a/src/PIL/BlpImagePlugin.py b/src/PIL/BlpImagePlugin.py index 9690ed2b0..7b97964a8 100644 --- a/src/PIL/BlpImagePlugin.py +++ b/src/PIL/BlpImagePlugin.py @@ -34,7 +34,6 @@ from io import BytesIO from . import Image, ImageFile - BLP_FORMAT_JPEG = 0 BLP_ENCODING_UNCOMPRESSED = 1 diff --git a/src/PIL/CurImagePlugin.py b/src/PIL/CurImagePlugin.py index 68afac06d..9e2d8c96f 100644 --- a/src/PIL/CurImagePlugin.py +++ b/src/PIL/CurImagePlugin.py @@ -18,7 +18,7 @@ from __future__ import print_function -from . import Image, BmpImagePlugin +from . import BmpImagePlugin, Image from ._binary import i8, i16le as i16, i32le as i32 # __version__ is deprecated and will be removed in a future version. Use diff --git a/src/PIL/DdsImagePlugin.py b/src/PIL/DdsImagePlugin.py index a9afb3849..b2d508942 100644 --- a/src/PIL/DdsImagePlugin.py +++ b/src/PIL/DdsImagePlugin.py @@ -12,8 +12,8 @@ Full text of the CC0 license: import struct from io import BytesIO -from . import Image, ImageFile +from . import Image, ImageFile # Magic ("DDS ") DDS_MAGIC = 0x20534444 diff --git a/src/PIL/EpsImagePlugin.py b/src/PIL/EpsImagePlugin.py index ea447f650..219f2dbb8 100644 --- a/src/PIL/EpsImagePlugin.py +++ b/src/PIL/EpsImagePlugin.py @@ -20,10 +20,11 @@ # See the README file for information on usage and redistribution. # -import re import io import os +import re import sys + from . import Image, ImageFile from ._binary import i32le as i32 diff --git a/src/PIL/FontFile.py b/src/PIL/FontFile.py index d7dc020c4..e57c2f3fd 100644 --- a/src/PIL/FontFile.py +++ b/src/PIL/FontFile.py @@ -17,6 +17,7 @@ from __future__ import print_function import os + from . import Image, _binary WIDTH = 800 diff --git a/src/PIL/FpxImagePlugin.py b/src/PIL/FpxImagePlugin.py index e2ff47289..15ebe0e3b 100644 --- a/src/PIL/FpxImagePlugin.py +++ b/src/PIL/FpxImagePlugin.py @@ -17,11 +17,11 @@ from __future__ import print_function -from . import Image, ImageFile -from ._binary import i32le as i32, i8 - import olefile +from . import Image, ImageFile +from ._binary import i8, i32le as i32 + # __version__ is deprecated and will be removed in a future version. Use # PIL.__version__ instead. __version__ = "0.1" diff --git a/src/PIL/FtexImagePlugin.py b/src/PIL/FtexImagePlugin.py index 76c7a6953..06f4a72d0 100644 --- a/src/PIL/FtexImagePlugin.py +++ b/src/PIL/FtexImagePlugin.py @@ -53,8 +53,8 @@ Note: All data is stored in little-Endian (Intel) byte order. import struct from io import BytesIO -from . import Image, ImageFile +from . import Image, ImageFile MAGIC = b"FTEX" FORMAT_DXT1 = 0 diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py index bbf1c603f..bbf6dc9d6 100644 --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -24,11 +24,11 @@ # See the README file for information on usage and redistribution. # -from . import Image, ImageFile, ImagePalette, ImageChops, ImageSequence -from ._binary import i8, i16le as i16, o8, o16le as o16 - import itertools +from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence +from ._binary import i8, i16le as i16, o8, o16le as o16 + # __version__ is deprecated and will be removed in a future version. Use # PIL.__version__ instead. __version__ = "0.9" diff --git a/src/PIL/GimpGradientFile.py b/src/PIL/GimpGradientFile.py index bc17b7060..f48e7f76e 100644 --- a/src/PIL/GimpGradientFile.py +++ b/src/PIL/GimpGradientFile.py @@ -13,7 +13,8 @@ # See the README file for information on usage and redistribution. # -from math import pi, log, sin, sqrt +from math import log, pi, sin, sqrt + from ._binary import o8 # -------------------------------------------------------------------- diff --git a/src/PIL/GimpPaletteFile.py b/src/PIL/GimpPaletteFile.py index 693829a23..2994bbeab 100644 --- a/src/PIL/GimpPaletteFile.py +++ b/src/PIL/GimpPaletteFile.py @@ -15,8 +15,8 @@ # import re -from ._binary import o8 +from ._binary import o8 ## # File handler for GIMP's palette format. diff --git a/src/PIL/IcnsImagePlugin.py b/src/PIL/IcnsImagePlugin.py index 9ab9d00f2..75ea18b6b 100644 --- a/src/PIL/IcnsImagePlugin.py +++ b/src/PIL/IcnsImagePlugin.py @@ -15,8 +15,6 @@ # See the README file for information on usage and redistribution. # -from PIL import Image, ImageFile, PngImagePlugin -from PIL._binary import i8 import io import os import shutil @@ -24,6 +22,9 @@ import struct import sys import tempfile +from PIL import Image, ImageFile, PngImagePlugin +from PIL._binary import i8 + enable_jpeg2k = hasattr(Image.core, "jp2klib_version") if enable_jpeg2k: from PIL import Jpeg2KImagePlugin diff --git a/src/PIL/IcoImagePlugin.py b/src/PIL/IcoImagePlugin.py index d6a6bc9d3..c4c72e78a 100644 --- a/src/PIL/IcoImagePlugin.py +++ b/src/PIL/IcoImagePlugin.py @@ -25,10 +25,10 @@ import struct import warnings from io import BytesIO +from math import ceil, log -from . import Image, ImageFile, BmpImagePlugin, PngImagePlugin +from . import BmpImagePlugin, Image, ImageFile, PngImagePlugin from ._binary import i8, i16le as i16, i32le as i32 -from math import log, ceil # __version__ is deprecated and will be removed in a future version. Use # PIL.__version__ instead. diff --git a/src/PIL/ImImagePlugin.py b/src/PIL/ImImagePlugin.py index 46deb29a0..77127fae6 100644 --- a/src/PIL/ImImagePlugin.py +++ b/src/PIL/ImImagePlugin.py @@ -27,6 +27,7 @@ import re + from . import Image, ImageFile, ImagePalette from ._binary import i8 diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 973325d8b..7d2bb1e7e 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -24,15 +24,22 @@ # See the README file for information on usage and redistribution. # +import atexit +import io +import logging +import math +import numbers +import os +import struct +import sys +import warnings + # VERSION was removed in Pillow 6.0.0. # PILLOW_VERSION is deprecated and will be removed in Pillow 7.0.0. # Use __version__ instead. -from . import PILLOW_VERSION, __version__, _plugins -from ._util import py3 - -import logging -import warnings -import math +from . import PILLOW_VERSION, ImageMode, TiffTags, __version__, _plugins +from ._binary import i8, i32le +from ._util import deferred_error, isPath, isStringType, py3 try: import builtins @@ -41,18 +48,6 @@ except ImportError: builtins = __builtin__ -from . import ImageMode, TiffTags -from ._binary import i8, i32le -from ._util import isPath, isStringType, deferred_error - -import os -import sys -import io -import struct -import atexit - -# type stuff -import numbers try: # Python 3 diff --git a/src/PIL/ImageCms.py b/src/PIL/ImageCms.py index 647a673f5..ed4eefc0d 100644 --- a/src/PIL/ImageCms.py +++ b/src/PIL/ImageCms.py @@ -16,9 +16,11 @@ # below for the original description. from __future__ import print_function + import sys from PIL import Image +from PIL._util import isStringType try: from PIL import _imagingcms @@ -28,7 +30,6 @@ except ImportError as ex: from ._util import deferred_error _imagingcms = deferred_error(ex) -from PIL._util import isStringType DESCRIPTION = """ pyCMS diff --git a/src/PIL/ImageColor.py b/src/PIL/ImageColor.py index d4e4e1f47..692d7d2c3 100644 --- a/src/PIL/ImageColor.py +++ b/src/PIL/ImageColor.py @@ -17,9 +17,10 @@ # See the README file for information on usage and redistribution. # -from . import Image import re +from . import Image + def getrgb(color): """ diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py index d43938281..7ccf9dacf 100644 --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -36,6 +36,7 @@ import numbers from . import Image, ImageColor from ._util import isStringType + """ A simple 2D drawing interface for PIL images.
diff --git a/src/PIL/ImageFile.py b/src/PIL/ImageFile.py index e5173a1fb..2b3d8e40a 100644 --- a/src/PIL/ImageFile.py +++ b/src/PIL/ImageFile.py @@ -27,11 +27,12 @@ # See the README file for information on usage and redistribution. # +import io +import struct +import sys + from . import Image from ._util import isPath -import io -import sys -import struct MAXBLOCK = 65536 diff --git a/src/PIL/ImageFont.py b/src/PIL/ImageFont.py index f43f95b9a..9012eafe5 100644 --- a/src/PIL/ImageFont.py +++ b/src/PIL/ImageFont.py @@ -25,11 +25,12 @@ # See the README file for information on usage and redistribution. # -from . import Image -from ._util import isDirectory, isPath, py3 import os import sys +from . import Image +from ._util import isDirectory, isPath, py3 + LAYOUT_BASIC = 0 LAYOUT_RAQM = 1 diff --git a/src/PIL/ImageGrab.py b/src/PIL/ImageGrab.py index faaa65467..8f359e229 100644 --- a/src/PIL/ImageGrab.py +++ b/src/PIL/ImageGrab.py @@ -15,10 +15,10 @@ # See the README file for information on usage and redistribution. # -from . import Image - import sys +from . import Image + if sys.platform == "win32": grabber = Image.core.grabscreen elif sys.platform == "darwin": diff --git a/src/PIL/ImageMorph.py b/src/PIL/ImageMorph.py index 058bb3728..61199234b 100644 --- a/src/PIL/ImageMorph.py +++ b/src/PIL/ImageMorph.py @@ -7,9 +7,10 @@ from __future__ import print_function -from . import Image, _imagingmorph import re +from . import Image, _imagingmorph + LUT_SIZE = 1 << 9 # fmt: off diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py index bc976f69b..cfdd5c02a 100644 --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -17,11 +17,11 @@ # See the README file for information on usage and redistribution. # +import functools +import operator + from . import Image from ._util import isStringType -import operator -import functools - # # helpers diff --git a/src/PIL/ImagePalette.py b/src/PIL/ImagePalette.py index a61cc328c..2d4f5cb6b 100644 --- a/src/PIL/ImagePalette.py +++ b/src/PIL/ImagePalette.py @@ -17,7 +17,8 @@ # import array -from . import ImageColor, GimpPaletteFile, GimpGradientFile, PaletteFile + +from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile class ImagePalette(object): diff --git a/src/PIL/ImagePath.py b/src/PIL/ImagePath.py index 8cbfec0d3..3d3538c97 100644 --- a/src/PIL/ImagePath.py +++ b/src/PIL/ImagePath.py @@ -16,5 +16,4 @@ from . import Image - Path = Image.core.path diff --git a/src/PIL/ImageQt.py b/src/PIL/ImageQt.py index b615d6dd4..2edb0a12b 100644 --- a/src/PIL/ImageQt.py +++ b/src/PIL/ImageQt.py @@ -16,11 +16,12 @@ # See the README file for information on usage and redistribution. # -from . import Image -from ._util import isPath, py3 -from io import BytesIO import sys import warnings +from io import BytesIO + +from . import Image +from ._util import isPath, py3 qt_versions = [["5", "PyQt5"], ["side2", "PySide2"], ["4", "PyQt4"], ["side", "PySide"]] diff --git a/src/PIL/ImageShow.py b/src/PIL/ImageShow.py index 82c60489b..29b15351d 100644 --- a/src/PIL/ImageShow.py +++ b/src/PIL/ImageShow.py @@ -14,12 +14,13 @@ from __future__ import print_function -from PIL import Image import os -import sys import subprocess +import sys import tempfile +from PIL import Image + if sys.version_info.major >= 3: from shlex import quote else: diff --git a/src/PIL/ImageStat.py b/src/PIL/ImageStat.py index 52b9961ee..9ba16fd85 100644 --- a/src/PIL/ImageStat.py +++ b/src/PIL/ImageStat.py @@ -21,9 +21,9 @@ # See the README file for information on usage and redistribution. # +import functools import math import operator -import functools class Stat(object): diff --git a/src/PIL/IptcImagePlugin.py b/src/PIL/IptcImagePlugin.py index 8b2f2ef32..aedf2e48c 100644 --- a/src/PIL/IptcImagePlugin.py +++ b/src/PIL/IptcImagePlugin.py @@ -17,11 +17,12 @@ from __future__ import print_function -from . import Image, ImageFile -from ._binary import i8, i16be as i16, i32be as i32, o8 import os import tempfile +from . import Image, ImageFile +from ._binary import i8, i16be as i16, i32be as i32, o8 + # __version__ is deprecated and will be removed in a future version. Use # PIL.__version__ instead. __version__ = "0.3" diff --git a/src/PIL/Jpeg2KImagePlugin.py b/src/PIL/Jpeg2KImagePlugin.py index 2a6b77c34..37f111778 100644 --- a/src/PIL/Jpeg2KImagePlugin.py +++ b/src/PIL/Jpeg2KImagePlugin.py @@ -12,10 +12,11 @@ # # See the README file for information on usage and redistribution. # -from . import Image, ImageFile -import struct -import os import io +import os +import struct + +from . import Image, ImageFile # __version__ is deprecated and will be removed in a future version. Use # PIL.__version__ instead. diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py index c8f987415..f1a2f7813 100644 --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -35,13 +35,14 @@ from __future__ import print_function import array -import struct import io +import struct import warnings + from . import Image, ImageFile, TiffImagePlugin -from ._binary import i8, o8, i16be as i16, i32be as i32 -from .JpegPresets import presets +from ._binary import i8, i16be as i16, i32be as i32, o8 from ._util import isStringType +from .JpegPresets import presets # __version__ is deprecated and will be removed in a future version. Use # PIL.__version__ instead. diff --git a/src/PIL/McIdasImagePlugin.py b/src/PIL/McIdasImagePlugin.py index df94f59b8..bddd33abb 100644 --- a/src/PIL/McIdasImagePlugin.py +++ b/src/PIL/McIdasImagePlugin.py @@ -17,6 +17,7 @@ # import struct + from . import Image, ImageFile # __version__ is deprecated and will be removed in a future version. Use diff --git a/src/PIL/MicImagePlugin.py b/src/PIL/MicImagePlugin.py index 1807e8a0e..b48905bda 100644 --- a/src/PIL/MicImagePlugin.py +++ b/src/PIL/MicImagePlugin.py @@ -17,10 +17,10 @@ # -from . import Image, TiffImagePlugin - import olefile +from . import Image, TiffImagePlugin + # __version__ is deprecated and will be removed in a future version. Use # PIL.__version__ instead. __version__ = "0.1" diff --git a/src/PIL/MspImagePlugin.py b/src/PIL/MspImagePlugin.py index f9be687e5..7315ab66e 100644 --- a/src/PIL/MspImagePlugin.py +++ b/src/PIL/MspImagePlugin.py @@ -23,10 +23,11 @@ # # See also: http://www.fileformat.info/format/mspaint/egff.htm -from . import Image, ImageFile -from ._binary import i16le as i16, o16le as o16, i8 -import struct import io +import struct + +from . import Image, ImageFile +from ._binary import i8, i16le as i16, o16le as o16 # __version__ is deprecated and will be removed in a future version. Use # PIL.__version__ instead. diff --git a/src/PIL/PSDraw.py b/src/PIL/PSDraw.py index f542e1505..f37701ce9 100644 --- a/src/PIL/PSDraw.py +++ b/src/PIL/PSDraw.py @@ -15,9 +15,10 @@ # See the README file for information on usage and redistribution. # +import sys + from . import EpsImagePlugin from ._util import py3 -import sys ## # Simple Postscript graphics interface. diff --git a/src/PIL/PaletteFile.py b/src/PIL/PaletteFile.py index 8a3d45ff2..ab22d5f0c 100644 --- a/src/PIL/PaletteFile.py +++ b/src/PIL/PaletteFile.py @@ -15,7 +15,6 @@ from ._binary import o8 - ## # File handler for Teragon-style palette files. diff --git a/src/PIL/PcfFontFile.py b/src/PIL/PcfFontFile.py index beaf5f58b..074124612 100644 --- a/src/PIL/PcfFontFile.py +++ b/src/PIL/PcfFontFile.py @@ -17,8 +17,9 @@ # import io -from . import Image, FontFile -from ._binary import i8, i16le as l16, i32le as l32, i16be as b16, i32be as b32 + +from . import FontFile, Image +from ._binary import i8, i16be as b16, i16le as l16, i32be as b32, i32le as l32 # -------------------------------------------------------------------- # declarations diff --git a/src/PIL/PcxImagePlugin.py b/src/PIL/PcxImagePlugin.py index 90778aa3c..397af8c10 100644 --- a/src/PIL/PcxImagePlugin.py +++ b/src/PIL/PcxImagePlugin.py @@ -27,6 +27,7 @@ import io import logging + from . import Image, ImageFile, ImagePalette from ._binary import i8, i16le as i16, o8, o16le as o16 diff --git a/src/PIL/PdfImagePlugin.py b/src/PIL/PdfImagePlugin.py index a45478821..1fd40f5ba 100644 --- a/src/PIL/PdfImagePlugin.py +++ b/src/PIL/PdfImagePlugin.py @@ -20,11 +20,12 @@ # Image plugin for PDF images (output only). ## -from . import Image, ImageFile, ImageSequence, PdfParser import io import os import time +from . import Image, ImageFile, ImageSequence, PdfParser + # __version__ is deprecated and will be removed in a future version. Use # PIL.__version__ instead. __version__ = "0.5" diff --git a/src/PIL/PdfParser.py b/src/PIL/PdfParser.py index 65cf77668..0ec6bba14 100644 --- a/src/PIL/PdfParser.py +++ b/src/PIL/PdfParser.py @@ -6,6 +6,7 @@ import os import re import time import zlib + from ._util import py3 try: diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index 10e18e4a0..658f5c04b 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -33,8 +33,8 @@ import logging import re -import zlib import struct +import zlib from . import Image, ImageFile, ImagePalette from ._binary import i8, i16be as i16, i32be as i32, o16be as o16, o32be as o32 diff --git a/src/PIL/PsdImagePlugin.py b/src/PIL/PsdImagePlugin.py index 576ea9024..9eb0c0966 100644 --- a/src/PIL/PsdImagePlugin.py +++ b/src/PIL/PsdImagePlugin.py @@ -21,6 +21,7 @@ __version__ = "0.4" import io + from . import Image, ImageFile, ImagePalette from ._binary import i8, i16be as i16, i32be as i32 diff --git a/src/PIL/PyAccess.py b/src/PIL/PyAccess.py index fa5bac433..2ab06f93f 100644 --- a/src/PIL/PyAccess.py +++ b/src/PIL/PyAccess.py @@ -25,7 +25,6 @@ import sys from cffi import FFI - logger = logging.getLogger(__name__) diff --git a/src/PIL/SgiImagePlugin.py b/src/PIL/SgiImagePlugin.py index e6d1b11c0..99408fdc3 100644 --- a/src/PIL/SgiImagePlugin.py +++ b/src/PIL/SgiImagePlugin.py @@ -22,12 +22,12 @@ # -from . import Image, ImageFile -from ._binary import i8, o8, i16be as i16 -from ._util import py3 -import struct import os +import struct +from . import Image, ImageFile +from ._binary import i8, i16be as i16, o8 +from ._util import py3 # __version__ is deprecated and will be removed in a future version. Use # PIL.__version__ instead. diff --git a/src/PIL/SpiderImagePlugin.py b/src/PIL/SpiderImagePlugin.py index 7b0ed3dbd..5663a5b53 100644 --- a/src/PIL/SpiderImagePlugin.py +++ b/src/PIL/SpiderImagePlugin.py @@ -35,11 +35,12 @@ from __future__ import print_function -from PIL import Image, ImageFile import os import struct import sys +from PIL import Image, ImageFile + def isInt(f): try: diff --git a/src/PIL/TarIO.py b/src/PIL/TarIO.py index b5227e484..e180b802c 100644 --- a/src/PIL/TarIO.py +++ b/src/PIL/TarIO.py @@ -16,8 +16,8 @@ import io import sys -from . import ContainerIO +from . import ContainerIO ## # A file object that provides read access to a given member of a TAR diff --git a/src/PIL/TgaImagePlugin.py b/src/PIL/TgaImagePlugin.py index 270754101..b1b351396 100644 --- a/src/PIL/TgaImagePlugin.py +++ b/src/PIL/TgaImagePlugin.py @@ -17,11 +17,11 @@ # +import warnings + from . import Image, ImageFile, ImagePalette from ._binary import i8, i16le as i16, o8, o16le as o16 -import warnings - # __version__ is deprecated and will be removed in a future version. Use # PIL.__version__ instead. __version__ = "0.3" diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index 94c7b3e2c..dabcf8eb4 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -41,21 +41,19 @@ from __future__ import division, print_function -from . import Image, ImageFile, ImagePalette, TiffTags -from ._binary import i8, o8 -from ._util import py3 - -from fractions import Fraction -from numbers import Number, Rational - +import distutils.version import io import itertools import os import struct import sys import warnings -import distutils.version +from fractions import Fraction +from numbers import Number, Rational +from . import Image, ImageFile, ImagePalette, TiffTags +from ._binary import i8, o8 +from ._util import py3 from .TiffTags import TYPES try: diff --git a/src/PIL/WebPImagePlugin.py b/src/PIL/WebPImagePlugin.py index 17c493650..18eda6d18 100644 --- a/src/PIL/WebPImagePlugin.py +++ b/src/PIL/WebPImagePlugin.py @@ -1,3 +1,5 @@ +from io import BytesIO + from . import Image, ImageFile try: @@ -6,7 +8,6 @@ try: SUPPORTED = True except ImportError: SUPPORTED = False -from io import BytesIO _VALID_WEBP_MODES = {"RGBX": True, "RGBA": True, "RGB": True} diff --git a/src/PIL/WmfImagePlugin.py b/src/PIL/WmfImagePlugin.py index 36ae37138..416af6fd7 100644 --- a/src/PIL/WmfImagePlugin.py +++ b/src/PIL/WmfImagePlugin.py @@ -22,10 +22,9 @@ from __future__ import print_function from . import Image, ImageFile -from ._binary import i16le as word, si16le as short, i32le as dword, si32le as _long +from ._binary import i16le as word, i32le as dword, si16le as short, si32le as _long from ._util import py3 - # __version__ is deprecated and will be removed in a future version. Use # PIL.__version__ instead. __version__ = "0.2" diff --git a/src/PIL/XbmImagePlugin.py b/src/PIL/XbmImagePlugin.py index 3afac688d..bc825c3f3 100644 --- a/src/PIL/XbmImagePlugin.py +++ b/src/PIL/XbmImagePlugin.py @@ -20,6 +20,7 @@ # import re + from . import Image, ImageFile # __version__ is deprecated and will be removed in a future version. Use diff --git a/src/PIL/XpmImagePlugin.py b/src/PIL/XpmImagePlugin.py index fa2c4caa5..275148827 100644 --- a/src/PIL/XpmImagePlugin.py +++ b/src/PIL/XpmImagePlugin.py @@ -16,6 +16,7 @@ import re + from . import Image, ImageFile, ImagePalette from ._binary import i8, o8 diff --git a/src/PIL/_binary.py b/src/PIL/_binary.py index e5ee0bf28..53b1ca956 100644 --- a/src/PIL/_binary.py +++ b/src/PIL/_binary.py @@ -11,7 +11,8 @@ # See the README file for information on usage and redistribution. # -from struct import unpack_from, pack +from struct import pack, unpack_from + from ._util import py3 if py3: diff --git a/src/PIL/features.py b/src/PIL/features.py index eff259dfc..9fd522368 100644 --- a/src/PIL/features.py +++ b/src/PIL/features.py @@ -5,6 +5,7 @@ import os import sys import PIL + from . import Image modules = { diff --git a/tox.ini b/tox.ini index 08fbebf05..2dc920371 100644 --- a/tox.ini +++ b/tox.ini @@ -26,9 +26,11 @@ deps = commands = black --check --diff . flake8 --statistics --count + isort --check-only --diff check-manifest deps = black check-manifest flake8 + isort skip_install = true diff --git a/winbuild/build.py b/winbuild/build.py index 79b768a1f..f3121283a 100755 --- a/winbuild/build.py +++ b/winbuild/build.py @@ -1,19 +1,19 @@ #!/usr/bin/env python3 -import subprocess -import shutil -import sys import getopt import os +import shutil +import subprocess +import sys from config import ( - compilers, - compiler_from_env, - pythons, - pyversion_from_env, - bit_from_env, VIRT_BASE, X64_EXT, + bit_from_env, + compiler_from_env, + compilers, + pythons, + pyversion_from_env, ) diff --git a/winbuild/build_dep.py b/winbuild/build_dep.py index 13ac7472e..a640d4279 100644 --- a/winbuild/build_dep.py +++ b/winbuild/build_dep.py @@ -1,10 +1,10 @@ -from unzip import unzip -from untar import untar import os -from fetch import fetch -from config import compilers, all_compilers, compiler_from_env, bit_from_env, libs from build import vc_setup +from config import all_compilers, bit_from_env, compiler_from_env, compilers, libs +from fetch import fetch +from untar import untar +from unzip import unzip def _relpath(*args): diff --git a/winbuild/get_pythons.py b/winbuild/get_pythons.py index 63326fa82..e24bb65f7 100644 --- a/winbuild/get_pythons.py +++ b/winbuild/get_pythons.py @@ -1,6 +1,7 @@ -from fetch import fetch import os +from fetch import fetch + if __name__ == "__main__": for version in ["2.7.15", "3.4.4"]: for platform in ["", ".amd64"]: diff --git a/winbuild/test.py b/winbuild/test.py index bb68fca27..559ecdec1 100755 --- a/winbuild/test.py +++ b/winbuild/test.py @@ -1,11 +1,11 @@ #!/usr/bin/env python3 -import subprocess -import os import glob +import os +import subprocess import sys -from config import pythons, VIRT_BASE, X64_EXT +from config import VIRT_BASE, X64_EXT, pythons def test_one(params):