Skip to content

Commit 4a4b90c

Browse files
authored
Autotype tests (#7756)
* autotyping: --none-return * autotyping: --scalar-return * autotyping: --int-param * autotyping: --float-param * autotyping: --str-param * autotyping: --annotate-named-param tmp_path:pathlib.Path
1 parent db43738 commit 4a4b90c

File tree

108 files changed

+1866
-1798
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1866
-1798
lines changed

Tests/bench_cffi_access.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
# Not running this test by default. No DOS against CI.
1010

1111

12-
def iterate_get(size, access):
12+
def iterate_get(size, access) -> None:
1313
(w, h) = size
1414
for x in range(w):
1515
for y in range(h):
1616
access[(x, y)]
1717

1818

19-
def iterate_set(size, access):
19+
def iterate_set(size, access) -> None:
2020
(w, h) = size
2121
for x in range(w):
2222
for y in range(h):
2323
access[(x, y)] = (x % 256, y % 256, 0)
2424

2525

26-
def timer(func, label, *args):
26+
def timer(func, label, *args) -> None:
2727
iterations = 5000
2828
starttime = time.time()
2929
for x in range(iterations):
@@ -38,7 +38,7 @@ def timer(func, label, *args):
3838
)
3939

4040

41-
def test_direct():
41+
def test_direct() -> None:
4242
im = hopper()
4343
im.load()
4444
# im = Image.new("RGB", (2000, 2000), (1, 3, 2))

Tests/test_bmp_reference.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
base = os.path.join("Tests", "images", "bmp")
1111

1212

13-
def get_files(d, ext=".bmp"):
13+
def get_files(d, ext: str = ".bmp"):
1414
return [
1515
os.path.join(base, d, f) for f in os.listdir(os.path.join(base, d)) if ext in f
1616
]
1717

1818

19-
def test_bad():
19+
def test_bad() -> None:
2020
"""These shouldn't crash/dos, but they shouldn't return anything
2121
either"""
2222
for f in get_files("b"):
@@ -56,7 +56,7 @@ def test_questionable():
5656
raise
5757

5858

59-
def test_good():
59+
def test_good() -> None:
6060
"""These should all work. There's a set of target files in the
6161
html directory that we can compare against."""
6262

Tests/test_box_blur.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
# fmt: on
1717

1818

19-
def test_imageops_box_blur():
19+
def test_imageops_box_blur() -> None:
2020
i = sample.filter(ImageFilter.BoxBlur(1))
2121
assert i.mode == sample.mode
2222
assert i.size == sample.size
2323
assert isinstance(i, Image.Image)
2424

2525

26-
def box_blur(image, radius=1, n=1):
26+
def box_blur(image, radius: int = 1, n: int = 1):
2727
return image._new(image.im.box_blur((radius, radius), n))
2828

2929

30-
def assert_image(im, data, delta=0):
30+
def assert_image(im, data, delta: int = 0) -> None:
3131
it = iter(im.getdata())
3232
for data_row in data:
3333
im_row = [next(it) for _ in range(im.size[0])]
@@ -37,15 +37,15 @@ def assert_image(im, data, delta=0):
3737
next(it)
3838

3939

40-
def assert_blur(im, radius, data, passes=1, delta=0):
40+
def assert_blur(im, radius, data, passes: int = 1, delta: int = 0) -> None:
4141
# check grayscale image
4242
assert_image(box_blur(im, radius, passes), data, delta)
4343
rgba = Image.merge("RGBA", (im, im, im, im))
4444
for band in box_blur(rgba, radius, passes).split():
4545
assert_image(band, data, delta)
4646

4747

48-
def test_color_modes():
48+
def test_color_modes() -> None:
4949
with pytest.raises(ValueError):
5050
box_blur(sample.convert("1"))
5151
with pytest.raises(ValueError):
@@ -65,7 +65,7 @@ def test_color_modes():
6565
box_blur(sample.convert("YCbCr"))
6666

6767

68-
def test_radius_0():
68+
def test_radius_0() -> None:
6969
assert_blur(
7070
sample,
7171
0,
@@ -81,7 +81,7 @@ def test_radius_0():
8181
)
8282

8383

84-
def test_radius_0_02():
84+
def test_radius_0_02() -> None:
8585
assert_blur(
8686
sample,
8787
0.02,
@@ -98,7 +98,7 @@ def test_radius_0_02():
9898
)
9999

100100

101-
def test_radius_0_05():
101+
def test_radius_0_05() -> None:
102102
assert_blur(
103103
sample,
104104
0.05,
@@ -115,7 +115,7 @@ def test_radius_0_05():
115115
)
116116

117117

118-
def test_radius_0_1():
118+
def test_radius_0_1() -> None:
119119
assert_blur(
120120
sample,
121121
0.1,
@@ -132,7 +132,7 @@ def test_radius_0_1():
132132
)
133133

134134

135-
def test_radius_0_5():
135+
def test_radius_0_5() -> None:
136136
assert_blur(
137137
sample,
138138
0.5,
@@ -149,7 +149,7 @@ def test_radius_0_5():
149149
)
150150

151151

152-
def test_radius_1():
152+
def test_radius_1() -> None:
153153
assert_blur(
154154
sample,
155155
1,
@@ -166,7 +166,7 @@ def test_radius_1():
166166
)
167167

168168

169-
def test_radius_1_5():
169+
def test_radius_1_5() -> None:
170170
assert_blur(
171171
sample,
172172
1.5,
@@ -183,7 +183,7 @@ def test_radius_1_5():
183183
)
184184

185185

186-
def test_radius_bigger_then_half():
186+
def test_radius_bigger_then_half() -> None:
187187
assert_blur(
188188
sample,
189189
3,
@@ -200,7 +200,7 @@ def test_radius_bigger_then_half():
200200
)
201201

202202

203-
def test_radius_bigger_then_width():
203+
def test_radius_bigger_then_width() -> None:
204204
assert_blur(
205205
sample,
206206
10,
@@ -215,7 +215,7 @@ def test_radius_bigger_then_width():
215215
)
216216

217217

218-
def test_extreme_large_radius():
218+
def test_extreme_large_radius() -> None:
219219
assert_blur(
220220
sample,
221221
600,
@@ -230,7 +230,7 @@ def test_extreme_large_radius():
230230
)
231231

232232

233-
def test_two_passes():
233+
def test_two_passes() -> None:
234234
assert_blur(
235235
sample,
236236
1,
@@ -248,7 +248,7 @@ def test_two_passes():
248248
)
249249

250250

251-
def test_three_passes():
251+
def test_three_passes() -> None:
252252
assert_blur(
253253
sample,
254254
1,

0 commit comments

Comments
 (0)