Skip to content

Commit 232bddd

Browse files
authored
Merge pull request #7755 from radarhere/type_hints
2 parents f55c9c6 + 7373149 commit 232bddd

25 files changed

Lines changed: 60 additions & 54 deletions

Tests/test_000_sanity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from PIL import Image
44

55

6-
def test_sanity():
6+
def test_sanity() -> None:
77
# Make sure we have the binary extension
88
Image.core.new("L", (100, 100))
99

Tests/test_binary.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
from PIL import _binary
44

55

6-
def test_standard():
6+
def test_standard() -> None:
77
assert _binary.i8(b"*") == 42
88
assert _binary.o8(42) == b"*"
99

1010

11-
def test_little_endian():
11+
def test_little_endian() -> None:
1212
assert _binary.i16le(b"\xff\xff\x00\x00") == 65535
1313
assert _binary.i32le(b"\xff\xff\x00\x00") == 65535
1414

1515
assert _binary.o16le(65535) == b"\xff\xff"
1616
assert _binary.o32le(65535) == b"\xff\xff\x00\x00"
1717

1818

19-
def test_big_endian():
19+
def test_big_endian() -> None:
2020
assert _binary.i16be(b"\x00\x00\xff\xff") == 0
2121
assert _binary.i32be(b"\x00\x00\xff\xff") == 65535
2222

Tests/test_file_cur.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
TEST_FILE = "Tests/images/deerstalker.cur"
88

99

10-
def test_sanity():
10+
def test_sanity() -> None:
1111
with Image.open(TEST_FILE) as im:
1212
assert im.size == (32, 32)
1313
assert isinstance(im, CurImagePlugin.CurImageFile)
@@ -17,7 +17,7 @@ def test_sanity():
1717
assert im.getpixel((16, 16)) == (84, 87, 86, 255)
1818

1919

20-
def test_invalid_file():
20+
def test_invalid_file() -> None:
2121
invalid_file = "Tests/images/flower.jpg"
2222

2323
with pytest.raises(SyntaxError):

Tests/test_file_ftex.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
from .helper import assert_image_equal_tofile, assert_image_similar
88

99

10-
def test_load_raw():
10+
def test_load_raw() -> None:
1111
with Image.open("Tests/images/ftex_uncompressed.ftu") as im:
1212
assert_image_equal_tofile(im, "Tests/images/ftex_uncompressed.png")
1313

1414

15-
def test_load_dxt1():
15+
def test_load_dxt1() -> None:
1616
with Image.open("Tests/images/ftex_dxt1.ftc") as im:
1717
with Image.open("Tests/images/ftex_dxt1.png") as target:
1818
assert_image_similar(im, target.convert("RGBA"), 15)
1919

2020

21-
def test_invalid_file():
21+
def test_invalid_file() -> None:
2222
invalid_file = "Tests/images/flower.jpg"
2323

2424
with pytest.raises(SyntaxError):

Tests/test_file_gbr.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77
from .helper import assert_image_equal_tofile
88

99

10-
def test_gbr_file():
10+
def test_gbr_file() -> None:
1111
with Image.open("Tests/images/gbr.gbr") as im:
1212
assert_image_equal_tofile(im, "Tests/images/gbr.png")
1313

1414

15-
def test_load():
15+
def test_load() -> None:
1616
with Image.open("Tests/images/gbr.gbr") as im:
1717
assert im.load()[0, 0] == (0, 0, 0, 0)
1818

1919
# Test again now that it has already been loaded once
2020
assert im.load()[0, 0] == (0, 0, 0, 0)
2121

2222

23-
def test_multiple_load_operations():
23+
def test_multiple_load_operations() -> None:
2424
with Image.open("Tests/images/gbr.gbr") as im:
2525
im.load()
2626
im.load()
2727
assert_image_equal_tofile(im, "Tests/images/gbr.png")
2828

2929

30-
def test_invalid_file():
30+
def test_invalid_file() -> None:
3131
invalid_file = "Tests/images/flower.jpg"
3232

3333
with pytest.raises(SyntaxError):

Tests/test_file_gd.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
TEST_GD_FILE = "Tests/images/hopper.gd"
88

99

10-
def test_sanity():
10+
def test_sanity() -> None:
1111
with GdImageFile.open(TEST_GD_FILE) as im:
1212
assert im.size == (128, 128)
1313
assert im.format == "GD"
1414

1515

16-
def test_bad_mode():
16+
def test_bad_mode() -> None:
1717
with pytest.raises(ValueError):
1818
GdImageFile.open(TEST_GD_FILE, "bad mode")
1919

2020

21-
def test_invalid_file():
21+
def test_invalid_file() -> None:
2222
invalid_file = "Tests/images/flower.jpg"
2323

2424
with pytest.raises(UnidentifiedImageError):

Tests/test_file_gimppalette.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from PIL.GimpPaletteFile import GimpPaletteFile
66

77

8-
def test_sanity():
8+
def test_sanity() -> None:
99
with open("Tests/images/test.gpl", "rb") as fp:
1010
GimpPaletteFile(fp)
1111

@@ -22,7 +22,7 @@ def test_sanity():
2222
GimpPaletteFile(fp)
2323

2424

25-
def test_get_palette():
25+
def test_get_palette() -> None:
2626
# Arrange
2727
with open("Tests/images/custom_gimp_palette.gpl", "rb") as fp:
2828
palette_file = GimpPaletteFile(fp)

Tests/test_file_imt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
from .helper import assert_image_equal_tofile
1010

1111

12-
def test_sanity():
12+
def test_sanity() -> None:
1313
with Image.open("Tests/images/bw_gradient.imt") as im:
1414
assert_image_equal_tofile(im, "Tests/images/bw_gradient.png")
1515

1616

1717
@pytest.mark.parametrize("data", (b"\n", b"\n-", b"width 1\n"))
18-
def test_invalid_file(data):
18+
def test_invalid_file(data: bytes) -> None:
1919
with io.BytesIO(data) as fp:
2020
with pytest.raises(SyntaxError):
2121
ImtImagePlugin.ImtImageFile(fp)

Tests/test_file_mcidas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
from .helper import assert_image_equal_tofile
88

99

10-
def test_invalid_file():
10+
def test_invalid_file() -> None:
1111
invalid_file = "Tests/images/flower.jpg"
1212

1313
with pytest.raises(SyntaxError):
1414
McIdasImagePlugin.McIdasImageFile(invalid_file)
1515

1616

17-
def test_valid_file():
17+
def test_valid_file() -> None:
1818
# Arrange
1919
# https://ghrc.nsstc.nasa.gov/hydro/details/cmx3g8
2020
# https://ghrc.nsstc.nasa.gov/pub/fieldCampaigns/camex3/cmx3g8/browse/

Tests/test_file_pcd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from PIL import Image
44

55

6-
def test_load_raw():
6+
def test_load_raw() -> None:
77
with Image.open("Tests/images/hopper.pcd") as im:
88
im.load() # should not segfault.
99

0 commit comments

Comments
 (0)