Skip to content

Commit a46c1c0

Browse files
authored
Update dependency mypy to v2 (#9653)
2 parents d136509 + d6e1ebf commit a46c1c0

29 files changed

Lines changed: 55 additions & 48 deletions

.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.20.2
1+
mypy==2.1.0
22
arro3-compute
33
arro3-core
44
IceSpringPySideStubs-PyQt6

Tests/test_file_jpeg.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,9 +1053,7 @@ def test_eof(self, monkeypatch: pytest.MonkeyPatch) -> None:
10531053
# Even though this decoder never says that it is finished
10541054
# the image should still end when there is no new data
10551055
class InfiniteMockPyDecoder(ImageFile.PyDecoder):
1056-
def decode(
1057-
self, buffer: bytes | Image.SupportsArrayInterface
1058-
) -> tuple[int, int]:
1056+
def decode(self, buffer: Image.DecoderInput) -> tuple[int, int]:
10591057
return 0, 0
10601058

10611059
Image.register_decoder("INFINITE", InfiniteMockPyDecoder)

Tests/test_file_pdf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def helper_save_as_pdf(tmp_path: Path, mode: str, **kwargs: Any) -> str:
4040
with open(outfile, "rb") as fp:
4141
contents = fp.read()
4242
size = tuple(
43-
float(d) for d in contents.split(b"/MediaBox [ 0 0 ")[1].split(b"]")[0].split()
43+
int(float(d))
44+
for d in contents.split(b"/MediaBox [ 0 0 ")[1].split(b"]")[0].split()
4445
)
4546
assert im.size == size
4647

Tests/test_format_lab.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def test_white() -> None:
1919

2020
assert k == (255, 128, 128)
2121

22-
assert L == (255,) * 100
23-
assert a == (128,) * 100
24-
assert b == (128,) * 100
22+
assert L == (255.0,) * 100
23+
assert a == (128.0,) * 100
24+
assert b == (128.0,) * 100
2525

2626

2727
def test_green() -> None:

Tests/test_image_frombytes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def test_sanity(data_type: str) -> None:
1212
im1 = hopper()
1313

14-
data = im1.tobytes()
14+
data: bytes | memoryview = im1.tobytes()
1515
if data_type == "memoryview":
1616
data = memoryview(data)
1717
im2 = Image.frombytes(im1.mode, im1.size, data)

Tests/test_imagecms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@ def test_simple_lab() -> None:
278278
a_data = i_lab.get_flattened_data(1)
279279
b_data = i_lab.get_flattened_data(2)
280280

281-
assert l_data == (137,) * 100
282-
assert a_data == (128,) * 100
283-
assert b_data == (128,) * 100
281+
assert l_data == (137.0,) * 100
282+
assert a_data == (128.0,) * 100
283+
assert b_data == (128.0,) * 100
284284

285285

286286
def test_lab_color() -> None:

Tests/test_imagefile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def __init__(self, mode: str, *args: Any) -> None:
260260

261261
super().__init__(mode, *args)
262262

263-
def decode(self, buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int]:
263+
def decode(self, buffer: Image.DecoderInput) -> tuple[int, int]:
264264
# eof
265265
return -1, 0
266266

Tests/test_imagefont.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ def test_variation_set_by_axes(font: ImageFont.FreeTypeFont) -> None:
821821
ids=("ls", "ms", "rs", "ma", "mt", "mm", "mb", "md"),
822822
)
823823
def test_anchor(
824-
layout_engine: ImageFont.Layout, anchor: str, left: int, top: int
824+
layout_engine: ImageFont.Layout, anchor: str, left: float, top: float
825825
) -> None:
826826
name, text = "quick", "Quick"
827827
path = f"Tests/images/test_anchor_{name}_{anchor}.png"

Tests/test_imagewin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_dib_frombytes_tobytes_roundtrip(self) -> None:
116116

117117
# Act
118118
# Make one the same as the using tobytes()/frombytes()
119-
test_buffer = dib1.tobytes()
119+
test_buffer: bytes | memoryview = dib1.tobytes()
120120
for datatype in ("bytes", "memoryview"):
121121
if datatype == "memoryview":
122122
test_buffer = memoryview(test_buffer)

docs/example/DdsImagePlugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def load_seek(self, pos: int) -> None:
258258
class DXT1Decoder(ImageFile.PyDecoder):
259259
_pulls_fd = True
260260

261-
def decode(self, buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int]:
261+
def decode(self, buffer: Image.DecoderInput) -> tuple[int, int]:
262262
assert self.fd is not None
263263
try:
264264
self.set_as_raw(_dxt1(self.fd, self.state.xsize, self.state.ysize))
@@ -271,7 +271,7 @@ def decode(self, buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int
271271
class DXT5Decoder(ImageFile.PyDecoder):
272272
_pulls_fd = True
273273

274-
def decode(self, buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int]:
274+
def decode(self, buffer: Image.DecoderInput) -> tuple[int, int]:
275275
assert self.fd is not None
276276
try:
277277
self.set_as_raw(_dxt5(self.fd, self.state.xsize, self.state.ysize))

0 commit comments

Comments
 (0)