Skip to content

Commit f3b05d6

Browse files
Update dependency mypy to v1.16.0 (#8991)
Co-authored-by: Andrew Murray <[email protected]>
1 parent 1bf32ae commit f3b05d6

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

.ci/requirements-mypy.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mypy==1.15.0
1+
mypy==1.16.0
22
IceSpringPySideStubs-PyQt6
33
IceSpringPySideStubs-PySide6
44
ipython

Tests/test_file_jpeg.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,16 @@ def test_cmyk(self) -> None:
145145
assert k > 0.9
146146
# roundtrip, and check again
147147
im = self.roundtrip(im)
148-
c, m, y, k = (x / 255.0 for x in im.getpixel((0, 0)))
148+
cmyk = im.getpixel((0, 0))
149+
assert isinstance(cmyk, tuple)
150+
c, m, y, k = (x / 255.0 for x in cmyk)
149151
assert c == 0.0
150152
assert m > 0.8
151153
assert y > 0.8
152154
assert k == 0.0
153-
c, m, y, k = (
154-
x / 255.0 for x in im.getpixel((im.size[0] - 1, im.size[1] - 1))
155-
)
155+
cmyk = im.getpixel((im.size[0] - 1, im.size[1] - 1))
156+
assert isinstance(cmyk, tuple)
157+
k = cmyk[3] / 255.0
156158
assert k > 0.9
157159

158160
def test_rgb(self) -> None:

Tests/test_image.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ def test_remap_palette(self) -> None:
671671
im_remapped = im.remap_palette(list(range(256)))
672672
assert_image_equal(im, im_remapped)
673673
assert im.palette is not None
674+
assert im_remapped.palette is not None
674675
assert im.palette.palette == im_remapped.palette.palette
675676

676677
# Test illegal image mode

src/PIL/GifImagePlugin.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import subprocess
3232
from enum import IntEnum
3333
from functools import cached_property
34-
from typing import IO, Any, Literal, NamedTuple, Union
34+
from typing import IO, Any, Literal, NamedTuple, Union, cast
3535

3636
from . import (
3737
Image,
@@ -350,12 +350,15 @@ def _rgb(color: int) -> tuple[int, int, int]:
350350
if self._frame_palette:
351351
if color * 3 + 3 > len(self._frame_palette.palette):
352352
color = 0
353-
return tuple(self._frame_palette.palette[color * 3 : color * 3 + 3])
353+
return cast(
354+
tuple[int, int, int],
355+
tuple(self._frame_palette.palette[color * 3 : color * 3 + 3]),
356+
)
354357
else:
355358
return (color, color, color)
356359

357360
self.dispose = None
358-
self.dispose_extent = frame_dispose_extent
361+
self.dispose_extent: tuple[int, int, int, int] | None = frame_dispose_extent
359362
if self.dispose_extent and self.disposal_method >= 2:
360363
try:
361364
if self.disposal_method == 2:

0 commit comments

Comments
 (0)