Skip to content

Commit 9ba0dc4

Browse files
committed
Updated type hints
1 parent e16a47b commit 9ba0dc4

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

Tests/test_file_ani.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
import pytest
66

7-
from PIL import Image
7+
from PIL import AniImagePlugin, Image
88

99
from .helper import assert_image_equal_tofile
1010

1111

1212
def test_aero_busy() -> None:
1313
with Image.open("Tests/images/ani/aero_busy.ani") as im:
14+
assert isinstance(im, AniImagePlugin)
1415
assert im.size == (64, 64)
1516
assert im.n_frames == 18
1617

@@ -29,6 +30,7 @@ def test_aero_busy() -> None:
2930

3031
def test_posy_busy() -> None:
3132
with Image.open("Tests/images/ani/posy_busy.ani") as im:
33+
assert isinstance(im, AniImagePlugin)
3234
assert im.size == (96, 96)
3335
assert im.n_frames == 77
3436

@@ -43,6 +45,7 @@ def test_posy_busy() -> None:
4345

4446
def test_seq_rate() -> None:
4547
with Image.open("Tests/images/ani/stopwtch.ani") as im:
48+
assert isinstance(im, AniImagePlugin)
4649
assert im.size == (32, 32)
4750
assert im.n_frames == 8
4851

@@ -122,6 +125,7 @@ def test_save() -> None:
122125
)
123126

124127
with Image.open(output, formats=["ANI"]) as im:
128+
assert isinstance(im, AniImagePlugin)
125129
assert im.n_frames == 6
126130
assert im.info["seq"] == [0, 2, 4, 1, 3, 5, 0, 1, 0, 1]
127131
assert im.info["rate"] == [1, 2, 3, 1, 2, 3, 1, 2, 3, 4]

Tests/test_file_cur.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def test_posy_link() -> None:
5959
assert im.getpixel((20, 20)) == (0, 0, 0, 255)
6060
assert im.getpixel((40, 40)) == (255, 255, 255, 255)
6161

62+
assert isinstance(im, CurImagePlugin.CurImageFile)
6263
im.size = (32, 32)
6364
im.load()
6465
assert im.getpixel((0, 0)) == (0, 0, 0, 0)

src/PIL/AniImagePlugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
283283

284284

285285
class AniFile:
286-
def __init__(self, fp: BytesIO) -> None:
286+
def __init__(self, fp: IO[bytes]) -> None:
287287
if not _accept(fp.read(4)):
288288
SyntaxError("Not an ANI file")
289289

@@ -394,6 +394,7 @@ class AniImageFile(ImageFile.ImageFile):
394394
format_description = "Windows Animated Cursor"
395395

396396
def _open(self) -> None:
397+
assert self.fp is not None
397398
self.ani = AniFile(self.fp)
398399
self.info["seq"] = self.ani.seq
399400
self.info["rate"] = self.ani.rate

0 commit comments

Comments
 (0)