From b976a8496df8ad741595decac321f5469a100d77 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 20 Jul 2024 08:07:12 +0000 Subject: [PATCH 1/3] Update dependency mypy to v1.11.0 --- .ci/requirements-mypy.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/requirements-mypy.txt b/.ci/requirements-mypy.txt index 6dd43248837..776bb0dbbf2 100644 --- a/.ci/requirements-mypy.txt +++ b/.ci/requirements-mypy.txt @@ -1 +1 @@ -mypy==1.10.1 +mypy==1.11.0 From 882a196a8f04f446c9ea6eaaac900fdecf220429 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 20 Jul 2024 18:59:27 +1000 Subject: [PATCH 2/3] Removed unused ignores --- Tests/test_file_png.py | 2 +- Tests/test_file_ppm.py | 2 +- Tests/test_psdraw.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index e2913e9444f..4958b22228b 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -776,7 +776,7 @@ class MyStdOut: mystdout: MyStdOut | BytesIO = MyStdOut() if buffer else BytesIO() - sys.stdout = mystdout # type: ignore[assignment] + sys.stdout = mystdout with Image.open(TEST_PNG_FILE) as im: im.save(sys.stdout, "PNG") diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py index d6451ec18b5..0a61830a40a 100644 --- a/Tests/test_file_ppm.py +++ b/Tests/test_file_ppm.py @@ -373,7 +373,7 @@ class MyStdOut: mystdout: MyStdOut | BytesIO = MyStdOut() if buffer else BytesIO() - sys.stdout = mystdout # type: ignore[assignment] + sys.stdout = mystdout with Image.open(TEST_FILE) as im: im.save(sys.stdout, "PPM") diff --git a/Tests/test_psdraw.py b/Tests/test_psdraw.py index 130ffa863a5..c3afa908937 100644 --- a/Tests/test_psdraw.py +++ b/Tests/test_psdraw.py @@ -59,7 +59,7 @@ class MyStdOut: mystdout: MyStdOut | BytesIO = MyStdOut() if buffer else BytesIO() - sys.stdout = mystdout # type: ignore[assignment] + sys.stdout = mystdout ps = PSDraw.PSDraw() _create_document(ps) From 38458a204cbbe1a83b458dd8d6be8762bc73ca99 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 20 Jul 2024 19:07:42 +1000 Subject: [PATCH 3/3] Corrected type hints --- Tests/test_file_mpo.py | 2 ++ src/PIL/JpegImagePlugin.py | 4 ++-- src/PIL/PngImagePlugin.py | 2 +- src/PIL/WebPImagePlugin.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Tests/test_file_mpo.py b/Tests/test_file_mpo.py index 5402fcb440d..e0f42a26649 100644 --- a/Tests/test_file_mpo.py +++ b/Tests/test_file_mpo.py @@ -85,7 +85,9 @@ def test_exif(test_file: str) -> None: im_reloaded = roundtrip(im_original, save_all=True, exif=im_original.getexif()) for im in (im_original, im_reloaded): + assert isinstance(im, MpoImagePlugin.MpoImageFile) info = im._getexif() + assert info is not None assert info[272] == "Nintendo 3DS" assert info[296] == 2 assert info[34665] == 188 diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py index af24faa5de2..d83d60b7b1b 100644 --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -468,7 +468,7 @@ def load_djpeg(self) -> None: self.tile = [] - def _getexif(self) -> dict[str, Any] | None: + def _getexif(self) -> dict[int, Any] | None: return _getexif(self) def _read_dpi_from_exif(self) -> None: @@ -504,7 +504,7 @@ def _getmp(self) -> dict[int, Any] | None: return _getmp(self) -def _getexif(self: JpegImageFile) -> dict[str, Any] | None: +def _getexif(self: JpegImageFile) -> dict[int, Any] | None: if "exif" not in self.info: return None return self.getexif()._get_merged_dict() diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index 247f908edaa..58db7777c39 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -1054,7 +1054,7 @@ def load_end(self) -> None: self._prev_im.paste(updated, self.dispose_extent, mask) self.im = self._prev_im - def _getexif(self) -> dict[str, Any] | None: + def _getexif(self) -> dict[int, Any] | None: if "exif" not in self.info: self.load() if "exif" not in self.info and "Raw profile type exif" not in self.info: diff --git a/src/PIL/WebPImagePlugin.py b/src/PIL/WebPImagePlugin.py index 011de9c6ac0..cec7963405b 100644 --- a/src/PIL/WebPImagePlugin.py +++ b/src/PIL/WebPImagePlugin.py @@ -96,7 +96,7 @@ def _open(self) -> None: # Initialize seek state self._reset(reset=False) - def _getexif(self) -> dict[str, Any] | None: + def _getexif(self) -> dict[int, Any] | None: if "exif" not in self.info: return None return self.getexif()._get_merged_dict()