diff --git a/Tests/test_box_blur.py b/Tests/test_box_blur.py index 07e62db8ced..cf94dc9c421 100644 --- a/Tests/test_box_blur.py +++ b/Tests/test_box_blur.py @@ -5,15 +5,13 @@ from PIL import Image, ImageFilter sample = Image.new("L", (7, 5)) -# fmt: off sample.putdata(sum([ [210, 50, 20, 10, 220, 230, 80], [190, 210, 20, 180, 170, 40, 110], [120, 210, 250, 60, 220, 0, 220], [220, 40, 230, 80, 130, 250, 40], [250, 0, 80, 30, 60, 20, 110], -], [])) -# fmt: on +], [])) # fmt: skip def test_imageops_box_blur() -> None: @@ -85,14 +83,12 @@ def test_radius_0() -> None: sample, 0, [ - # fmt: off [210, 50, 20, 10, 220, 230, 80], [190, 210, 20, 180, 170, 40, 110], [120, 210, 250, 60, 220, 0, 220], [220, 40, 230, 80, 130, 250, 40], [250, 0, 80, 30, 60, 20, 110], - # fmt: on - ], + ], # fmt: skip ) @@ -101,14 +97,12 @@ def test_radius_0_02() -> None: sample, 0.02, [ - # fmt: off [206, 55, 20, 17, 215, 223, 83], [189, 203, 31, 171, 169, 46, 110], [125, 206, 241, 69, 210, 13, 210], [215, 49, 221, 82, 131, 235, 48], [244, 7, 80, 32, 60, 27, 107], - # fmt: on - ], + ], # fmt: skip delta=2, ) @@ -118,14 +112,12 @@ def test_radius_0_05() -> None: sample, 0.05, [ - # fmt: off [202, 62, 22, 27, 209, 215, 88], [188, 194, 44, 161, 168, 56, 111], [131, 201, 229, 81, 198, 31, 198], [209, 62, 209, 86, 133, 216, 59], [237, 17, 80, 36, 60, 35, 103], - # fmt: on - ], + ], # fmt: skip delta=2, ) @@ -135,14 +127,12 @@ def test_radius_0_1() -> None: sample, 0.1, [ - # fmt: off [196, 72, 24, 40, 200, 203, 93], [187, 183, 62, 148, 166, 68, 111], [139, 193, 213, 96, 182, 54, 182], [201, 78, 193, 91, 133, 191, 73], [227, 31, 80, 42, 61, 47, 99], - # fmt: on - ], + ], # fmt: skip delta=1, ) @@ -152,14 +142,12 @@ def test_radius_0_5() -> None: sample, 0.5, [ - # fmt: off [176, 101, 46, 83, 163, 165, 111], [176, 149, 108, 122, 144, 120, 117], [164, 171, 159, 141, 134, 119, 129], [170, 136, 133, 114, 116, 124, 109], [184, 95, 72, 70, 69, 81, 89], - # fmt: on - ], + ], # fmt: skip delta=1, ) @@ -169,14 +157,12 @@ def test_radius_1() -> None: sample, 1, [ - # fmt: off [170, 109, 63, 97, 146, 153, 116], [168, 142, 112, 128, 126, 143, 121], [169, 166, 142, 149, 126, 131, 114], [159, 156, 109, 127, 94, 117, 112], [164, 128, 63, 87, 76, 89, 90], - # fmt: on - ], + ], # fmt: skip delta=1, ) @@ -186,14 +172,12 @@ def test_radius_1_5() -> None: sample, 1.5, [ - # fmt: off [155, 120, 105, 112, 124, 137, 130], [160, 136, 124, 125, 127, 134, 130], [166, 147, 130, 125, 120, 121, 119], [168, 145, 119, 109, 103, 105, 110], [168, 134, 96, 85, 85, 89, 97], - # fmt: on - ], + ], # fmt: skip delta=1, ) @@ -203,14 +187,12 @@ def test_radius_bigger_then_half() -> None: sample, 3, [ - # fmt: off [144, 145, 142, 128, 114, 115, 117], [148, 145, 137, 122, 109, 111, 112], [152, 145, 131, 117, 103, 107, 108], [156, 144, 126, 111, 97, 102, 103], [160, 144, 121, 106, 92, 98, 99], - # fmt: on - ], + ], # fmt: skip delta=1, ) @@ -225,7 +207,7 @@ def test_radius_bigger_then_width() -> None: [159, 154, 148, 142, 136, 130, 124], [160, 154, 148, 142, 137, 131, 125], [160, 155, 149, 143, 137, 131, 125], - ], + ], delta=0, ) @@ -250,14 +232,12 @@ def test_two_passes() -> None: sample, 1, [ - # fmt: off [153, 123, 102, 109, 132, 135, 129], [159, 138, 123, 121, 133, 131, 126], [162, 147, 136, 124, 127, 121, 121], [159, 140, 125, 108, 111, 106, 108], [154, 126, 105, 87, 94, 93, 97], - # fmt: on - ], + ], # fmt: skip passes=2, delta=1, ) @@ -268,14 +248,12 @@ def test_three_passes() -> None: sample, 1, [ - # fmt: off [146, 131, 116, 118, 126, 131, 130], [151, 138, 125, 123, 126, 128, 127], [154, 143, 129, 123, 120, 120, 119], [152, 139, 122, 113, 108, 108, 108], [148, 132, 112, 102, 97, 99, 100], - # fmt: on - ], + ], # fmt: skip passes=3, delta=1, ) diff --git a/Tests/test_color_lut.py b/Tests/test_color_lut.py index 26945ae1a69..82294abcf90 100644 --- a/Tests/test_color_lut.py +++ b/Tests/test_color_lut.py @@ -258,18 +258,21 @@ def test_channels_order(self) -> None: ) # Reverse channels by splitting and using table - # fmt: off - assert_image_equal( - Image.merge('RGB', im.split()[::-1]), - im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR, - 3, (2, 2, 2), [ - 0, 0, 0, 0, 0, 1, - 0, 1, 0, 0, 1, 1, + table = [ + 0, 0, 0, 0, 0, 1, + 0, 1, 0, 0, 1, 1, - 1, 0, 0, 1, 0, 1, - 1, 1, 0, 1, 1, 1, - ]))) - # fmt: on + 1, 0, 0, 1, 0, 1, + 1, 1, 0, 1, 1, 1, + ] # fmt: skip + assert_image_equal( + Image.merge("RGB", im.split()[::-1]), + im._new( + im.im.color_lut_3d( + "RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), table + ) + ), + ) def test_overflow(self) -> None: g = Image.linear_gradient("L") @@ -282,17 +285,17 @@ def test_overflow(self) -> None: ], ) - # fmt: off - transformed = im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR, - 3, (2, 2, 2), - [ - -1, -1, -1, 2, -1, -1, - -1, 2, -1, 2, 2, -1, - - -1, -1, 2, 2, -1, 2, - -1, 2, 2, 2, 2, 2, - ])).load() - # fmt: on + table = [ + -1, -1, -1, 2, -1, -1, + -1, 2, -1, 2, 2, -1, + + -1, -1, 2, 2, -1, 2, + -1, 2, 2, 2, 2, 2, + ] # fmt: skip + + transformed = im._new( + im.im.color_lut_3d("RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), table) + ).load() assert transformed is not None assert transformed[0, 0] == (0, 0, 255) assert transformed[50, 50] == (0, 0, 255) @@ -303,17 +306,16 @@ def test_overflow(self) -> None: assert transformed[255, 255] == (255, 255, 0) assert transformed[205, 205] == (255, 255, 0) - # fmt: off - transformed = im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR, - 3, (2, 2, 2), - [ - -3, -3, -3, 5, -3, -3, - -3, 5, -3, 5, 5, -3, - - -3, -3, 5, 5, -3, 5, - -3, 5, 5, 5, 5, 5, - ])).load() - # fmt: on + table = [ + -3, -3, -3, 5, -3, -3, + -3, 5, -3, 5, 5, -3, + + -3, -3, 5, 5, -3, 5, + -3, 5, 5, 5, 5, 5, + ] # fmt: skip + transformed = im._new( + im.im.color_lut_3d("RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), table) + ).load() assert transformed is not None assert transformed[0, 0] == (0, 0, 255) assert transformed[50, 50] == (0, 0, 255) @@ -359,11 +361,10 @@ def test_convert_table(self) -> None: assert tuple(lut.size) == (2, 2, 2) assert lut.name == "Color 3D LUT" - # fmt: off lut = ImageFilter.Color3DLUT((2, 2, 2), [ (0, 1, 2), (3, 4, 5), (6, 7, 8), (9, 10, 11), - (12, 13, 14), (15, 16, 17), (18, 19, 20), (21, 22, 23)]) - # fmt: on + (12, 13, 14), (15, 16, 17), (18, 19, 20), (21, 22, 23), + ]) # fmt: skip assert tuple(lut.size) == (2, 2, 2) assert lut.table == list(range(24)) @@ -484,11 +485,10 @@ def test_3_channels(self) -> None: lut = ImageFilter.Color3DLUT.generate(5, lambda r, g, b: (r, g, b)) assert tuple(lut.size) == (5, 5, 5) assert lut.name == "Color 3D LUT" - # fmt: off assert lut.table[:24] == [ 0.0, 0.0, 0.0, 0.25, 0.0, 0.0, 0.5, 0.0, 0.0, 0.75, 0.0, 0.0, - 1.0, 0.0, 0.0, 0.0, 0.25, 0.0, 0.25, 0.25, 0.0, 0.5, 0.25, 0.0] - # fmt: on + 1.0, 0.0, 0.0, 0.0, 0.25, 0.0, 0.25, 0.25, 0.0, 0.5, 0.25, 0.0, + ] # fmt: skip def test_4_channels(self) -> None: lut = ImageFilter.Color3DLUT.generate( @@ -496,12 +496,10 @@ def test_4_channels(self) -> None: ) assert tuple(lut.size) == (5, 5, 5) assert lut.name == "Color 3D LUT" - # fmt: off assert lut.table[:24] == [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, 0.125, 0.0, 0.5, 0.0, 0.25, 0.0, 0.75, 0.0, 0.375, 0.0, 1.0, 0.0, 0.5, 0.0, 0.0, 0.25, 0.125 - ] - # fmt: on + ] # fmt: skip def test_apply(self) -> None: lut = ImageFilter.Color3DLUT.generate(5, lambda r, g, b: (r, g, b)) @@ -559,11 +557,10 @@ def test_3_to_4_channels(self) -> None: assert tuple(lut.size) == tuple(source.size) assert len(lut.table) != len(source.table) assert lut.table != source.table - # fmt: off assert lut.table[:16] == [ - 0.0, 0.0, 0.0, 1, 0.2**2, 0.0, 0.0, 1, - 0.4**2, 0.0, 0.0, 1, 0.6**2, 0.0, 0.0, 1] - # fmt: on + 0.0, 0.0, 0.0, 1, 0.2**2, 0.0, 0.0, 1, + 0.4**2, 0.0, 0.0, 1, 0.6**2, 0.0, 0.0, 1, + ] # fmt: skip def test_4_to_3_channels(self) -> None: source = ImageFilter.Color3DLUT.generate( @@ -575,11 +572,10 @@ def test_4_to_3_channels(self) -> None: assert tuple(lut.size) == tuple(source.size) assert len(lut.table) != len(source.table) assert lut.table != source.table - # fmt: off assert lut.table[:18] == [ - 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 0.0, 1.0, 1.0, - 1.0, 0.96, 1.0, 0.75, 0.96, 1.0, 0.0, 0.96, 1.0] - # fmt: on + 1.0, 1.0, 1.0, 0.75, 1.0, 1.0, 0.0, 1.0, 1.0, + 1.0, 0.96, 1.0, 0.75, 0.96, 1.0, 0.0, 0.96, 1.0, + ] # fmt: skip def test_4_to_4_channels(self) -> None: source = ImageFilter.Color3DLUT.generate( @@ -589,11 +585,10 @@ def test_4_to_4_channels(self) -> None: assert tuple(lut.size) == tuple(source.size) assert len(lut.table) == len(source.table) assert lut.table != source.table - # fmt: off assert lut.table[:16] == [ - 0.0, 0.0, 0.0, 0.5, 0.2**2, 0.0, 0.0, 0.5, - 0.4**2, 0.0, 0.0, 0.5, 0.6**2, 0.0, 0.0, 0.5] - # fmt: on + 0.0, 0.0, 0.0, 0.5, 0.2**2, 0.0, 0.0, 0.5, + 0.4**2, 0.0, 0.0, 0.5, 0.6**2, 0.0, 0.0, 0.5, + ] # fmt: skip def test_with_normals_3_channels(self) -> None: source = ImageFilter.Color3DLUT.generate( @@ -605,11 +600,10 @@ def test_with_normals_3_channels(self) -> None: assert tuple(lut.size) == tuple(source.size) assert len(lut.table) == len(source.table) assert lut.table != source.table - # fmt: off assert lut.table[:18] == [ 0.0, 0.0, 0.0, 0.16, 0.0, 0.0, 0.24, 0.0, 0.0, - 0.24, 0.0, 0.0, 0.8 - (0.8**2), 0, 0, 0, 0, 0] - # fmt: on + 0.24, 0.0, 0.0, 0.8 - (0.8**2), 0, 0, 0, 0, 0, + ] # fmt: skip def test_with_normals_4_channels(self) -> None: source = ImageFilter.Color3DLUT.generate( @@ -622,8 +616,7 @@ def test_with_normals_4_channels(self) -> None: assert tuple(lut.size) == tuple(source.size) assert len(lut.table) == len(source.table) assert lut.table != source.table - # fmt: off assert lut.table[:16] == [ 0.0, 0.0, 0.0, 0.5, 0.25, 0.0, 0.0, 0.5, - 0.0, 0.0, 0.0, 0.5, 0.0, 0.16, 0.0, 0.5] - # fmt: on + 0.0, 0.0, 0.0, 0.5, 0.0, 0.16, 0.0, 0.5, + ] # fmt: skip diff --git a/Tests/test_image_convert.py b/Tests/test_image_convert.py index 547a6c2c678..332f0306dad 100644 --- a/Tests/test_image_convert.py +++ b/Tests/test_image_convert.py @@ -290,36 +290,32 @@ def test_p2pa_palette() -> None: assert im_pa.getpalette() == im.getpalette() +rgb2xyz_matrix = ( + 0.412453, 0.357580, 0.180423, 0, + 0.212671, 0.715160, 0.072169, 0, + 0.019334, 0.119193, 0.950227, 0, +) # fmt: skip + + def test_matrix_illegal_conversion() -> None: # Arrange im = hopper("CMYK") - # fmt: off - matrix = ( - 0.412453, 0.357580, 0.180423, 0, - 0.212671, 0.715160, 0.072169, 0, - 0.019334, 0.119193, 0.950227, 0) - # fmt: on assert im.mode != "RGB" # Act / Assert with pytest.raises(ValueError): - im.convert(mode="CMYK", matrix=matrix) + im.convert(mode="CMYK", matrix=rgb2xyz_matrix) def test_matrix_wrong_mode() -> None: # Arrange im = hopper("L") - # fmt: off - matrix = ( - 0.412453, 0.357580, 0.180423, 0, - 0.212671, 0.715160, 0.072169, 0, - 0.019334, 0.119193, 0.950227, 0) - # fmt: on + assert im.mode == "L" # Act / Assert with pytest.raises(ValueError): - im.convert(mode="L", matrix=matrix) + im.convert(mode="L", matrix=rgb2xyz_matrix) @pytest.mark.parametrize("mode", ("RGB", "L")) @@ -327,17 +323,11 @@ def test_matrix_xyz(mode: str) -> None: # Arrange im = hopper("RGB") im.info["transparency"] = (255, 0, 0) - # fmt: off - matrix = ( - 0.412453, 0.357580, 0.180423, 0, - 0.212671, 0.715160, 0.072169, 0, - 0.019334, 0.119193, 0.950227, 0) - # fmt: on assert im.mode == "RGB" # Act # Convert an RGB image to the CIE XYZ colour space - converted_im = im.convert(mode=mode, matrix=matrix) + converted_im = im.convert(mode=mode, matrix=rgb2xyz_matrix) # Assert assert converted_im.mode == mode @@ -354,12 +344,11 @@ def test_matrix_xyz(mode: str) -> None: def test_matrix_identity() -> None: # Arrange im = hopper("RGB") - # fmt: off identity_matrix = ( 1, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 1, 0) - # fmt: on + 0, 0, 1, 0, + ) # fmt: skip assert im.mode == "RGB" # Act diff --git a/Tests/test_image_filter.py b/Tests/test_image_filter.py index 693745eae47..4fa24e2f9c5 100644 --- a/Tests/test_image_filter.py +++ b/Tests/test_image_filter.py @@ -176,17 +176,14 @@ def test_kernel_not_enough_coefficients() -> None: "mode", ("L", "LA", "I", "I;16", "I;16L", "I;16B", "I;16N", "RGB", "CMYK") ) def test_consistency_3x3(mode: str) -> None: + matrix = ( + -1, -1, 0, + -1, 0, 1, + 0, 1, 1, + ) # fmt: skip with Image.open("Tests/images/hopper.bmp") as source: with Image.open("Tests/images/hopper_emboss.bmp") as reference: - kernel = ImageFilter.Kernel( - (3, 3), - # fmt: off - (-1, -1, 0, - -1, 0, 1, - 0, 1, 1), - # fmt: on - 0.3, - ) + kernel = ImageFilter.Kernel((3, 3), matrix, 0.3) assert_image_equal(source.filter(kernel), reference) @@ -194,19 +191,16 @@ def test_consistency_3x3(mode: str) -> None: "mode", ("L", "LA", "I", "I;16", "I;16L", "I;16B", "I;16N", "RGB", "CMYK") ) def test_consistency_5x5(mode: str) -> None: + matrix = ( + -1, -1, -1, -1, 0, + -1, -1, -1, 0, 1, + -1, -1, 0, 1, 1, + -1, 0, 1, 1, 1, + 0, 1, 1, 1, 1, + ) # fmt: skip with Image.open("Tests/images/hopper.bmp") as source: with Image.open("Tests/images/hopper_emboss_more.bmp") as reference: - kernel = ImageFilter.Kernel( - (5, 5), - # fmt: off - (-1, -1, -1, -1, 0, - -1, -1, -1, 0, 1, - -1, -1, 0, 1, 1, - -1, 0, 1, 1, 1, - 0, 1, 1, 1, 1), - # fmt: on - 0.3, - ) + kernel = ImageFilter.Kernel((5, 5), matrix, 0.3) assert_image_equal(source.filter(kernel), reference) diff --git a/Tests/test_image_resample.py b/Tests/test_image_resample.py index 61b2842cc66..37b2eee4dcc 100644 --- a/Tests/test_image_resample.py +++ b/Tests/test_image_resample.py @@ -111,10 +111,8 @@ def serialize_image(self, image: Image.Image) -> str: def test_reduce_box(self, mode: str) -> None: case = self.make_case(mode, (8, 8), 0xE1) case = case.resize((4, 4), Image.Resampling.BOX) - # fmt: off data = ("e1 e1" - "e1 e1") - # fmt: on + "e1 e1") # fmt: skip for channel in case.split(): self.check_case(channel, self.make_sample(data, (4, 4))) @@ -122,10 +120,8 @@ def test_reduce_box(self, mode: str) -> None: def test_reduce_bilinear(self, mode: str) -> None: case = self.make_case(mode, (8, 8), 0xE1) case = case.resize((4, 4), Image.Resampling.BILINEAR) - # fmt: off data = ("e1 c9" - "c9 b7") - # fmt: on + "c9 b7") # fmt: skip for channel in case.split(): self.check_case(channel, self.make_sample(data, (4, 4))) @@ -133,10 +129,8 @@ def test_reduce_bilinear(self, mode: str) -> None: def test_reduce_hamming(self, mode: str) -> None: case = self.make_case(mode, (8, 8), 0xE1) case = case.resize((4, 4), Image.Resampling.HAMMING) - # fmt: off data = ("e1 da" - "da d3") - # fmt: on + "da d3") # fmt: skip for channel in case.split(): self.check_case(channel, self.make_sample(data, (4, 4))) @@ -144,11 +138,9 @@ def test_reduce_hamming(self, mode: str) -> None: def test_reduce_bicubic(self, mode: str) -> None: case = self.make_case(mode, (12, 12), 0xE1) case = case.resize((6, 6), Image.Resampling.BICUBIC) - # fmt: off data = ("e1 e3 d4" "e3 e5 d6" - "d4 d6 c9") - # fmt: on + "d4 d6 c9") # fmt: skip for channel in case.split(): self.check_case(channel, self.make_sample(data, (6, 6))) @@ -156,12 +148,10 @@ def test_reduce_bicubic(self, mode: str) -> None: def test_reduce_lanczos(self, mode: str) -> None: case = self.make_case(mode, (16, 16), 0xE1) case = case.resize((8, 8), Image.Resampling.LANCZOS) - # fmt: off data = ("e1 e0 e4 d7" "e0 df e3 d6" "e4 e3 e7 da" - "d7 d6 d9 ce") - # fmt: on + "d7 d6 d9 ce") # fmt: skip for channel in case.split(): self.check_case(channel, self.make_sample(data, (8, 8))) @@ -169,10 +159,8 @@ def test_reduce_lanczos(self, mode: str) -> None: def test_enlarge_box(self, mode: str) -> None: case = self.make_case(mode, (2, 2), 0xE1) case = case.resize((4, 4), Image.Resampling.BOX) - # fmt: off data = ("e1 e1" - "e1 e1") - # fmt: on + "e1 e1") # fmt: skip for channel in case.split(): self.check_case(channel, self.make_sample(data, (4, 4))) @@ -180,10 +168,8 @@ def test_enlarge_box(self, mode: str) -> None: def test_enlarge_bilinear(self, mode: str) -> None: case = self.make_case(mode, (2, 2), 0xE1) case = case.resize((4, 4), Image.Resampling.BILINEAR) - # fmt: off data = ("e1 b0" - "b0 98") - # fmt: on + "b0 98") # fmt: skip for channel in case.split(): self.check_case(channel, self.make_sample(data, (4, 4))) @@ -191,10 +177,8 @@ def test_enlarge_bilinear(self, mode: str) -> None: def test_enlarge_hamming(self, mode: str) -> None: case = self.make_case(mode, (2, 2), 0xE1) case = case.resize((4, 4), Image.Resampling.HAMMING) - # fmt: off data = ("e1 d2" - "d2 c5") - # fmt: on + "d2 c5") # fmt: skip for channel in case.split(): self.check_case(channel, self.make_sample(data, (4, 4))) @@ -202,12 +186,10 @@ def test_enlarge_hamming(self, mode: str) -> None: def test_enlarge_bicubic(self, mode: str) -> None: case = self.make_case(mode, (4, 4), 0xE1) case = case.resize((8, 8), Image.Resampling.BICUBIC) - # fmt: off data = ("e1 e5 ee b9" "e5 e9 f3 bc" "ee f3 fd c1" - "b9 bc c1 a2") - # fmt: on + "b9 bc c1 a2") # fmt: skip for channel in case.split(): self.check_case(channel, self.make_sample(data, (8, 8))) diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py index 7b8051486d4..20184e5272c 100644 --- a/Tests/test_imagecms.py +++ b/Tests/test_imagecms.py @@ -550,13 +550,11 @@ def assert_aux_channel_preserved( ) -> None: def create_test_image() -> Image.Image: # set up test image with something interesting in the tested aux channel. - # fmt: off nine_grid_deltas = [ (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), - ] - # fmt: on + ] # fmt: skip chans = [] bands = ImageMode.getmode(mode).bands for band_ndx in range(len(bands)): diff --git a/checks/check_jpeg_leaks.py b/checks/check_jpeg_leaks.py index 2c27ce1d5af..80d988aee28 100644 --- a/checks/check_jpeg_leaks.py +++ b/checks/check_jpeg_leaks.py @@ -81,7 +81,6 @@ standard_l_qtable = ( - # fmt: off 16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, @@ -90,11 +89,9 @@ 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, 103, 121, 120, 101, 72, 92, 95, 98, 112, 100, 103, 99, - # fmt: on -) +) # fmt: skip standard_chrominance_qtable = ( - # fmt: off 17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99, @@ -103,8 +100,7 @@ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - # fmt: on -) +) # fmt: skip @pytest.mark.parametrize( diff --git a/src/PIL/ImageFilter.py b/src/PIL/ImageFilter.py index 823365af076..428ceb1aaa9 100644 --- a/src/PIL/ImageFilter.py +++ b/src/PIL/ImageFilter.py @@ -268,116 +268,96 @@ def filter(self, image: _imaging.ImagingCore) -> _imaging.ImagingCore: class BLUR(BuiltinFilter): name = "Blur" - # fmt: off filterargs = (5, 5), 16, 0, ( 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, - ) - # fmt: on + ) # fmt: skip class CONTOUR(BuiltinFilter): name = "Contour" - # fmt: off filterargs = (3, 3), 1, 255, ( -1, -1, -1, -1, 8, -1, -1, -1, -1, - ) - # fmt: on + ) # fmt: skip class DETAIL(BuiltinFilter): name = "Detail" - # fmt: off filterargs = (3, 3), 6, 0, ( 0, -1, 0, -1, 10, -1, 0, -1, 0, - ) - # fmt: on + ) # fmt: skip class EDGE_ENHANCE(BuiltinFilter): name = "Edge-enhance" - # fmt: off filterargs = (3, 3), 2, 0, ( -1, -1, -1, -1, 10, -1, -1, -1, -1, - ) - # fmt: on + ) # fmt: skip class EDGE_ENHANCE_MORE(BuiltinFilter): name = "Edge-enhance More" - # fmt: off filterargs = (3, 3), 1, 0, ( -1, -1, -1, -1, 9, -1, -1, -1, -1, - ) - # fmt: on + ) # fmt: skip class EMBOSS(BuiltinFilter): name = "Emboss" - # fmt: off filterargs = (3, 3), 1, 128, ( -1, 0, 0, 0, 1, 0, 0, 0, 0, - ) - # fmt: on + ) # fmt: skip class FIND_EDGES(BuiltinFilter): name = "Find Edges" - # fmt: off filterargs = (3, 3), 1, 0, ( -1, -1, -1, -1, 8, -1, -1, -1, -1, - ) - # fmt: on + ) # fmt: skip class SHARPEN(BuiltinFilter): name = "Sharpen" - # fmt: off filterargs = (3, 3), 16, 0, ( -2, -2, -2, -2, 32, -2, -2, -2, -2, - ) - # fmt: on + ) # fmt: skip class SMOOTH(BuiltinFilter): name = "Smooth" - # fmt: off filterargs = (3, 3), 13, 0, ( 1, 1, 1, 1, 5, 1, 1, 1, 1, - ) - # fmt: on + ) # fmt: skip class SMOOTH_MORE(BuiltinFilter): name = "Smooth More" - # fmt: off filterargs = (5, 5), 100, 0, ( 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 5, 44, 5, 1, 1, 5, 5, 5, 1, 1, 1, 1, 1, 1, - ) - # fmt: on + ) # fmt: skip class Color3DLUT(MultibandFilter): diff --git a/src/PIL/ImageMorph.py b/src/PIL/ImageMorph.py index 9fcd8d78db4..104d029efc2 100644 --- a/src/PIL/ImageMorph.py +++ b/src/PIL/ImageMorph.py @@ -12,18 +12,16 @@ LUT_SIZE = 1 << 9 -# fmt: off ROTATION_MATRIX = [ 6, 3, 0, 7, 4, 1, 8, 5, 2, -] +] # fmt: skip MIRROR_MATRIX = [ 2, 1, 0, 5, 4, 3, 8, 7, 6, -] -# fmt: on +] # fmt: skip class LutBuilder: diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py index c0802f4e6a0..5d4347818d4 100644 --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -626,7 +626,6 @@ def _getmp(self: JpegImageFile) -> dict[int, Any] | None: "YCbCr": "YCbCr", } -# fmt: off zigzag_index = ( 0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, @@ -636,14 +635,13 @@ def _getmp(self: JpegImageFile) -> dict[int, Any] | None: 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63, -) +) # fmt: skip samplings = { (1, 1, 1, 1, 1, 1): 0, (2, 1, 1, 1, 1, 1): 1, (2, 2, 1, 1, 1, 1): 2, } -# fmt: on def get_sampling(im: Image.Image) -> int: diff --git a/src/PIL/JpegPresets.py b/src/PIL/JpegPresets.py index d0e64a35ee1..d5dcf6c68d0 100644 --- a/src/PIL/JpegPresets.py +++ b/src/PIL/JpegPresets.py @@ -65,7 +65,6 @@ from __future__ import annotations -# fmt: off presets = { 'web_low': {'subsampling': 2, # "4:2:0" 'quantization': [ @@ -238,5 +237,4 @@ 15, 12, 12, 12, 12, 12, 12, 12, 15, 12, 12, 12, 12, 12, 12, 12] ]}, -} -# fmt: on +} # fmt: skip diff --git a/src/PIL/PalmImagePlugin.py b/src/PIL/PalmImagePlugin.py index 232adf3d3bb..c2681c4f388 100644 --- a/src/PIL/PalmImagePlugin.py +++ b/src/PIL/PalmImagePlugin.py @@ -14,7 +14,6 @@ from ._binary import o8 from ._binary import o16be as o16b -# fmt: off _Palm8BitColormapValues = ( (255, 255, 255), (255, 204, 255), (255, 153, 255), (255, 102, 255), (255, 51, 255), (255, 0, 255), (255, 255, 204), (255, 204, 204), @@ -79,8 +78,8 @@ (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), - (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)) -# fmt: on + (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), +) # fmt: skip # so build a prototype image to be used for palette resampling