Skip to content

Commit c73796d

Browse files
authored
Merge pull request #8733 from radarhere/tuple
2 parents dd2bb39 + a37702d commit c73796d

File tree

10 files changed

+18
-26
lines changed

10 files changed

+18
-26
lines changed

Tests/test_color_lut.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class TestColorLut3DCoreAPI:
2020
def generate_identity_table(
2121
self, channels: int, size: int | tuple[int, int, int]
22-
) -> tuple[int, int, int, int, list[float]]:
22+
) -> tuple[int, tuple[int, int, int], list[float]]:
2323
if isinstance(size, tuple):
2424
size_1d, size_2d, size_3d = size
2525
else:
@@ -39,9 +39,7 @@ def generate_identity_table(
3939
]
4040
return (
4141
channels,
42-
size_1d,
43-
size_2d,
44-
size_3d,
42+
(size_1d, size_2d, size_3d),
4543
[item for sublist in table for item in sublist],
4644
)
4745

@@ -89,21 +87,21 @@ def test_wrong_args(self) -> None:
8987

9088
with pytest.raises(ValueError, match=r"size1D \* size2D \* size3D"):
9189
im.im.color_lut_3d(
92-
"RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, [0, 0, 0] * 7
90+
"RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), [0, 0, 0] * 7
9391
)
9492

9593
with pytest.raises(ValueError, match=r"size1D \* size2D \* size3D"):
9694
im.im.color_lut_3d(
97-
"RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, [0, 0, 0] * 9
95+
"RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), [0, 0, 0] * 9
9896
)
9997

10098
with pytest.raises(TypeError):
10199
im.im.color_lut_3d(
102-
"RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, [0, 0, "0"] * 8
100+
"RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), [0, 0, "0"] * 8
103101
)
104102

105103
with pytest.raises(TypeError):
106-
im.im.color_lut_3d("RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, 16)
104+
im.im.color_lut_3d("RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), 16)
107105

108106
@pytest.mark.parametrize(
109107
"lut_mode, table_channels, table_size",
@@ -264,7 +262,7 @@ def test_channels_order(self) -> None:
264262
assert_image_equal(
265263
Image.merge('RGB', im.split()[::-1]),
266264
im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR,
267-
3, 2, 2, 2, [
265+
3, (2, 2, 2), [
268266
0, 0, 0, 0, 0, 1,
269267
0, 1, 0, 0, 1, 1,
270268

@@ -286,7 +284,7 @@ def test_overflow(self) -> None:
286284

287285
# fmt: off
288286
transformed = im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR,
289-
3, 2, 2, 2,
287+
3, (2, 2, 2),
290288
[
291289
-1, -1, -1, 2, -1, -1,
292290
-1, 2, -1, 2, 2, -1,
@@ -307,7 +305,7 @@ def test_overflow(self) -> None:
307305

308306
# fmt: off
309307
transformed = im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR,
310-
3, 2, 2, 2,
308+
3, (2, 2, 2),
311309
[
312310
-3, -3, -3, 5, -3, -3,
313311
-3, 5, -3, 5, 5, -3,

src/PIL/ImageFilter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,6 @@ def filter(self, image: _imaging.ImagingCore) -> _imaging.ImagingCore:
598598
self.mode or image.mode,
599599
Image.Resampling.BILINEAR,
600600
self.channels,
601-
self.size[0],
602-
self.size[1],
603-
self.size[2],
601+
self.size,
604602
self.table,
605603
)

src/PIL/ImageFont.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,7 @@ def fill(width: int, height: int) -> Image.core.ImagingCore:
647647
kwargs.get("stroke_filled", False),
648648
anchor,
649649
ink,
650-
start[0],
651-
start[1],
650+
start,
652651
)
653652

654653
def font_variant(

src/PIL/JpegImagePlugin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,7 @@ def validate_qtables(
816816
optimize,
817817
info.get("keep_rgb", False),
818818
info.get("streamtype", 0),
819-
dpi[0],
820-
dpi[1],
819+
dpi,
821820
subsampling,
822821
info.get("restart_marker_blocks", 0),
823822
info.get("restart_marker_rows", 0),

src/PIL/WebPImagePlugin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ def _save_all(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
223223

224224
# Setup the WebP animation encoder
225225
enc = _webp.WebPAnimEncoder(
226-
im.size[0],
227-
im.size[1],
226+
im.size,
228227
background,
229228
loop,
230229
minimize_size,

src/PIL/_imagingft.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ class Font:
3131
stroke_filled: bool,
3232
anchor: str | None,
3333
foreground_ink_long: int,
34-
x_start: float,
35-
y_start: float,
34+
start: tuple[float, float],
3635
/,
3736
) -> tuple[_imaging.ImagingCore, tuple[int, int]]: ...
3837
def getsize(

src/_imaging.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ _color_lut_3d(ImagingObject *self, PyObject *args) {
866866

867867
if (!PyArg_ParseTuple(
868868
args,
869-
"siiiiiO:color_lut_3d",
869+
"sii(iii)O:color_lut_3d",
870870
&mode,
871871
&filter,
872872
&table_channels,

src/_imagingft.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ font_render(FontObject *self, PyObject *args) {
854854

855855
if (!PyArg_ParseTuple(
856856
args,
857-
"OO|zzOzfpzLffO:render",
857+
"OO|zzOzfpzL(ff):render",
858858
&string,
859859
&fill,
860860
&mode,

src/_webp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ _anim_encoder_new(PyObject *self, PyObject *args) {
164164

165165
if (!PyArg_ParseTuple(
166166
args,
167-
"iiIiiiiii",
167+
"(ii)Iiiiiii",
168168
&width,
169169
&height,
170170
&bgcolor,

src/encode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ PyImaging_JpegEncoderNew(PyObject *self, PyObject *args) {
10971097

10981098
if (!PyArg_ParseTuple(
10991099
args,
1100-
"ss|nnnnpnnnnnnOz#y#y#",
1100+
"ss|nnnnpn(nn)nnnOz#y#y#",
11011101
&mode,
11021102
&rawmode,
11031103
&quality,

0 commit comments

Comments
 (0)