diff --git a/Tests/check_imaging_leaks.py b/Tests/check_imaging_leaks.py index eb9426eee..0c41b6da1 100755 --- a/Tests/check_imaging_leaks.py +++ b/Tests/check_imaging_leaks.py @@ -25,9 +25,8 @@ class TestImagingLeaks(PillowTestCase): if i < min_iterations: mem_limit = mem + 1 continue - self.assertLessEqual(mem, mem_limit, - msg='memory usage limit exceeded after %d iterations' - % (i + 1)) + msg = 'memory usage limit exceeded after %d iterations' % (i + 1) + self.assertLessEqual(mem, mem_limit, msg) def test_leak_putdata(self): im = Image.new('RGB', (25, 25)) diff --git a/Tests/helper.py b/Tests/helper.py index b6ef6dc13..8fb34848b 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -272,8 +272,8 @@ class PillowLeakTestCase(PillowTestCase): for cycle in range(self.iterations): core() mem = (self._get_mem_usage() - start_mem) - self.assertLess(mem, self.mem_limit, - msg='memory usage limit exceeded in iteration %d' % cycle) + msg = 'memory usage limit exceeded in iteration %d' % cycle + self.assertLess(mem, self.mem_limit, msg) # helpers diff --git a/Tests/test_bmp_reference.py b/Tests/test_bmp_reference.py index 015a9ebdf..af25f7162 100644 --- a/Tests/test_bmp_reference.py +++ b/Tests/test_bmp_reference.py @@ -42,7 +42,8 @@ class TestBmpReference(PillowTestCase): im = Image.open(f) im.load() if os.path.basename(f) not in supported: - print("Please add %s to the partially supported bmp specs." % f) + print("Please add %s to the partially supported" + " bmp specs." % f) except Exception: # as msg: if os.path.basename(f) in supported: raise diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 4209e3911..cbfc63d74 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -58,7 +58,8 @@ class TestFileTiff(PillowTestCase): self.assertEqual(im.mode, "RGBA") self.assertEqual(im.size, (52, 53)) - self.assertEqual(im.tile, [('raw', (0, 0, 52, 53), 160, ('RGBA', 0, 1))]) + self.assertEqual(im.tile, + [('raw', (0, 0, 52, 53), 160, ('RGBA', 0, 1))]) im.load() def test_set_legacy_api(self): diff --git a/Tests/test_file_tiff_metadata.py b/Tests/test_file_tiff_metadata.py index 0a958454c..d1e2b577e 100644 --- a/Tests/test_file_tiff_metadata.py +++ b/Tests/test_file_tiff_metadata.py @@ -56,7 +56,8 @@ class TestFileTiffMetadata(PillowTestCase): loaded = Image.open(f) self.assertEqual(loaded.tag[ImageJMetaDataByteCounts], (len(bindata),)) - self.assertEqual(loaded.tag_v2[ImageJMetaDataByteCounts], (len(bindata),)) + self.assertEqual(loaded.tag_v2[ImageJMetaDataByteCounts], + (len(bindata),)) self.assertEqual(loaded.tag[ImageJMetaData], bindata) self.assertEqual(loaded.tag_v2[ImageJMetaData], bindata) @@ -75,8 +76,10 @@ class TestFileTiffMetadata(PillowTestCase): img.save(f, tiffinfo=info) loaded = Image.open(f) - self.assertEqual(loaded.tag[ImageJMetaDataByteCounts], (8, len(bindata) - 8)) - self.assertEqual(loaded.tag_v2[ImageJMetaDataByteCounts], (8, len(bindata) - 8)) + self.assertEqual(loaded.tag[ImageJMetaDataByteCounts], + (8, len(bindata) - 8)) + self.assertEqual(loaded.tag_v2[ImageJMetaDataByteCounts], + (8, len(bindata) - 8)) def test_read_metadata(self): img = Image.open('Tests/images/hopper_g4.tif') @@ -133,8 +136,8 @@ class TestFileTiffMetadata(PillowTestCase): if isinstance(v, IFDRational): original[k] = IFDRational(*_limit_rational(v, 2**31)) if isinstance(v, tuple) and isinstance(v[0], IFDRational): - original[k] = tuple([IFDRational( - *_limit_rational(elt, 2**31)) for elt in v]) + original[k] = tuple([IFDRational(*_limit_rational(elt, 2**31)) + for elt in v]) ignored = ['StripByteCounts', 'RowsPerStrip', 'PageNumber', 'StripOffsets'] @@ -184,7 +187,8 @@ class TestFileTiffMetadata(PillowTestCase): def test_iccprofile_binary(self): # https://github.com/python-pillow/Pillow/issues/1526 - # We should be able to load this, but probably won't be able to save it. + # We should be able to load this, + # but probably won't be able to save it. im = Image.open('Tests/images/hopper.iccprofile_binary.tif') self.assertEqual(im.tag_v2.tagtype[34675], 1) diff --git a/Tests/test_file_webp.py b/Tests/test_file_webp.py index 25d3cb462..fa01cf93e 100644 --- a/Tests/test_file_webp.py +++ b/Tests/test_file_webp.py @@ -38,7 +38,8 @@ class TestFileWebp(PillowTestCase): # generated with: # dwebp -ppm ../../Tests/images/hopper.webp -o hopper_webp_bits.ppm - self.assert_image_similar_tofile(image, 'Tests/images/hopper_webp_bits.ppm', 1.0) + self.assert_image_similar_tofile( + image, 'Tests/images/hopper_webp_bits.ppm', 1.0) def test_write_rgb(self): """ @@ -58,7 +59,8 @@ class TestFileWebp(PillowTestCase): image.getdata() # generated with: dwebp -ppm temp.webp -o hopper_webp_write.ppm - self.assert_image_similar_tofile(image, 'Tests/images/hopper_webp_write.ppm', 12.0) + self.assert_image_similar_tofile( + image, 'Tests/images/hopper_webp_write.ppm', 12.0) # This test asserts that the images are similar. If the average pixel # difference between the two images is less than the epsilon value, diff --git a/Tests/test_image_convert.py b/Tests/test_image_convert.py index 84c1cc82e..1b3815d80 100644 --- a/Tests/test_image_convert.py +++ b/Tests/test_image_convert.py @@ -204,7 +204,8 @@ class TestImageConvert(PillowTestCase): target = Image.open('Tests/images/hopper-XYZ.png') if converted_im.mode == 'RGB': self.assert_image_similar(converted_im, target, 3) - self.assertEqual(converted_im.info['transparency'], (105, 54, 4)) + self.assertEqual(converted_im.info['transparency'], + (105, 54, 4)) else: self.assert_image_similar(converted_im, target.getchannel(0), 1) diff --git a/Tests/test_lib_pack.py b/Tests/test_lib_pack.py index 635b5679a..2fb7da281 100644 --- a/Tests/test_lib_pack.py +++ b/Tests/test_lib_pack.py @@ -221,7 +221,8 @@ class TestLibUnpack(PillowTestCase): data_len = data * len(pixels) data = bytes(bytearray(range(1, data_len + 1))) - im = Image.frombytes(mode, (len(pixels), 1), data, "raw", rawmode, 0, 1) + im = Image.frombytes(mode, (len(pixels), 1), data, + "raw", rawmode, 0, 1) for x, pixel in enumerate(pixels): self.assertEqual(pixel, im.getpixel((x, 0))) @@ -265,9 +266,11 @@ class TestLibUnpack(PillowTestCase): def test_P(self): self.assert_unpack("P", "P;1", b'\xe4', 1, 1, 1, 0, 0, 1, 0, 0) self.assert_unpack("P", "P;2", b'\xe4', 3, 2, 1, 0) - # self.assert_unpack("P", "P;2L", b'\xe4', 1, 1, 1, 0) # erroneous? + # erroneous? + # self.assert_unpack("P", "P;2L", b'\xe4', 1, 1, 1, 0) self.assert_unpack("P", "P;4", b'\x02\xef', 0, 2, 14, 15) - # self.assert_unpack("P", "P;4L", b'\x02\xef', 2, 10, 10, 0) # erroneous? + # erroneous? + # self.assert_unpack("P", "P;4L", b'\x02\xef', 2, 10, 10, 0) self.assert_unpack("P", "P", 1, 1, 2, 3, 4) self.assert_unpack("P", "P;R", 1, 128, 64, 192, 32) @@ -373,7 +376,8 @@ class TestLibUnpack(PillowTestCase): self.assert_unpack( "RGBA", "YCCA;P", b']bE\x04\xdd\xbej\xed57T\xce\xac\xce:\x11', # random data - (0, 161, 0, 4), (255, 255, 255, 237), (27, 158, 0, 206), (0, 118, 0, 17)) + (0, 161, 0, 4), (255, 255, 255, 237), + (27, 158, 0, 206), (0, 118, 0, 17)) self.assert_unpack( "RGBA", "R", 1, (1, 0, 0, 0), (2, 0, 0, 0), (3, 0, 0, 0)) self.assert_unpack( @@ -425,7 +429,8 @@ class TestLibUnpack(PillowTestCase): self.assert_unpack( "RGBX", "YCC;P", b'D]\x9c\x82\x1a\x91\xfaOC\xe7J\x12', # random data - (127, 102, 0, X), (192, 227, 0, X), (213, 255, 170, X), (98, 255, 133, X)) + (127, 102, 0, X), (192, 227, 0, X), + (213, 255, 170, X), (98, 255, 133, X)) self.assert_unpack("RGBX", "R", 1, (1, 0, 0, 0), (2, 0, 0, 0), (3, 0, 0, 0)) self.assert_unpack("RGBX", "G", 1, diff --git a/Tests/test_pdfparser.py b/Tests/test_pdfparser.py index 42c813520..b7373842e 100644 --- a/Tests/test_pdfparser.py +++ b/Tests/test_pdfparser.py @@ -26,7 +26,9 @@ class TestPdfParser(PillowTestCase): def test_parsing(self): self.assertEqual(PdfParser.interpret_name(b"Name#23Hash"), b"Name#Hash") - self.assertEqual(PdfParser.interpret_name(b"Name#23Hash", as_text=True), "Name#Hash") + self.assertEqual(PdfParser.interpret_name( + b"Name#23Hash", as_text=True + ), "Name#Hash") self.assertEqual(PdfParser.get_value(b"1 2 R ", 0), (IndirectReference(1, 2), 5)) self.assertEqual(PdfParser.get_value(b"true[", 0), (True, 4)) @@ -72,7 +74,9 @@ class TestPdfParser(PillowTestCase): self.assertIsInstance(a, list) self.assertEqual(len(a), 4) self.assertEqual(a[0], PdfName("Name")) - s = PdfParser.get_value(b"<>\nstream\nabcde\nendstream<<...", 0)[0] + s = PdfParser.get_value( + b"<>\nstream\nabcde\nendstream<<...", 0 + )[0] self.assertIsInstance(s, PdfStream) self.assertEqual(s.dictionary.Name, "value") self.assertEqual(s.decode(), b"abcde") diff --git a/src/PIL/GdImageFile.py b/src/PIL/GdImageFile.py index 2ca1e8218..1a0b2c910 100644 --- a/src/PIL/GdImageFile.py +++ b/src/PIL/GdImageFile.py @@ -61,7 +61,8 @@ class GdImageFile(ImageFile.ImageFile): self.palette = ImagePalette.raw("XBGR", s[7+trueColorOffset+4:7+trueColorOffset+4+256*4]) - self.tile = [("raw", (0, 0)+self.size, 7+trueColorOffset+4+256*4, ("L", 0, 1))] + self.tile = [("raw", (0, 0)+self.size, 7+trueColorOffset+4+256*4, + ("L", 0, 1))] def open(fp, mode="r"): diff --git a/src/PIL/ImageFont.py b/src/PIL/ImageFont.py index 099ccc4ff..5384a725b 100644 --- a/src/PIL/ImageFont.py +++ b/src/PIL/ImageFont.py @@ -162,7 +162,8 @@ class FreeTypeFont(object): size, offset = self.font.getsize(text, direction, features) return (size[0] + offset[0], size[1] + offset[1]) - def getsize_multiline(self, text, direction=None, spacing=4, features=None): + def getsize_multiline(self, text, direction=None, + spacing=4, features=None): max_width = 0 lines = self._multiline_split(text) line_spacing = self.getsize('A')[1] + spacing diff --git a/src/PIL/ImageQt.py b/src/PIL/ImageQt.py index 5ce685916..e60261360 100644 --- a/src/PIL/ImageQt.py +++ b/src/PIL/ImageQt.py @@ -28,7 +28,8 @@ qt_versions = [ ['side', 'PySide'] ] # If a version has already been imported, attempt it first -qt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules, reverse=True) +qt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules, + reverse=True) for qt_version, qt_module in qt_versions: try: if qt_module == 'PyQt5':