Skip to content

Commit 6dc6d6d

Browse files
authored
Merge pull request #7731 from radarhere/type_hints_oss_fuzz
2 parents c23904a + 81b5c5d commit 6dc6d6d

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

Tests/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def assert_tuple_approx_equal(actuals, targets, threshold, msg):
158158
assert value, msg + ": " + repr(actuals) + " != " + repr(targets)
159159

160160

161-
def skip_unless_feature(feature):
161+
def skip_unless_feature(feature: str) -> pytest.MarkDecorator:
162162
reason = f"{feature} not available"
163163
return pytest.mark.skipif(not features.check(feature), reason=reason)
164164

Tests/oss-fuzz/fuzz_font.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import fuzzers
2424

2525

26-
def TestOneInput(data):
26+
def TestOneInput(data: bytes) -> None:
2727
try:
2828
fuzzers.fuzz_font(data)
2929
except Exception:
@@ -32,7 +32,7 @@ def TestOneInput(data):
3232
pass
3333

3434

35-
def main():
35+
def main() -> None:
3636
fuzzers.enable_decompressionbomb_error()
3737
atheris.Setup(sys.argv, TestOneInput)
3838
atheris.Fuzz()

Tests/oss-fuzz/fuzz_pillow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import fuzzers
2424

2525

26-
def TestOneInput(data):
26+
def TestOneInput(data: bytes) -> None:
2727
try:
2828
fuzzers.fuzz_image(data)
2929
except Exception:
@@ -32,7 +32,7 @@ def TestOneInput(data):
3232
pass
3333

3434

35-
def main():
35+
def main() -> None:
3636
fuzzers.enable_decompressionbomb_error()
3737
atheris.Setup(sys.argv, TestOneInput)
3838
atheris.Fuzz()

Tests/oss-fuzz/fuzzers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
from PIL import Image, ImageDraw, ImageFile, ImageFilter, ImageFont
66

77

8-
def enable_decompressionbomb_error():
8+
def enable_decompressionbomb_error() -> None:
99
ImageFile.LOAD_TRUNCATED_IMAGES = True
1010
warnings.filterwarnings("ignore")
1111
warnings.simplefilter("error", Image.DecompressionBombWarning)
1212

1313

14-
def disable_decompressionbomb_error():
14+
def disable_decompressionbomb_error() -> None:
1515
ImageFile.LOAD_TRUNCATED_IMAGES = False
1616
warnings.resetwarnings()
1717

1818

19-
def fuzz_image(data):
19+
def fuzz_image(data: bytes) -> None:
2020
# This will fail on some images in the corpus, as we have many
2121
# invalid images in the test suite.
2222
with Image.open(io.BytesIO(data)) as im:
@@ -25,7 +25,7 @@ def fuzz_image(data):
2525
im.save(io.BytesIO(), "BMP")
2626

2727

28-
def fuzz_font(data):
28+
def fuzz_font(data: bytes) -> None:
2929
wrapper = io.BytesIO(data)
3030
try:
3131
font = ImageFont.truetype(wrapper)

Tests/oss-fuzz/test_fuzzers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"path",
2424
subprocess.check_output("find Tests/images -type f", shell=True).split(b"\n"),
2525
)
26-
def test_fuzz_images(path):
26+
def test_fuzz_images(path: str) -> None:
2727
fuzzers.enable_decompressionbomb_error()
2828
try:
2929
with open(path, "rb") as f:
@@ -54,7 +54,7 @@ def test_fuzz_images(path):
5454
@pytest.mark.parametrize(
5555
"path", subprocess.check_output("find Tests/fonts -type f", shell=True).split(b"\n")
5656
)
57-
def test_fuzz_fonts(path):
57+
def test_fuzz_fonts(path: str) -> None:
5858
if not path:
5959
return
6060
with open(path, "rb") as f:

0 commit comments

Comments
 (0)