Skip to content

Autotype tests #7756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
autotyping: --int-param
  • Loading branch information
hugovk committed Jan 27, 2024
commit 0b99b25a406ddf75b3becb5556754e16d4fde8c9
6 changes: 3 additions & 3 deletions Tests/test_box_blur.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def test_imageops_box_blur() -> None:
assert isinstance(i, Image.Image)


def box_blur(image, radius=1, n=1):
def box_blur(image, radius: int = 1, n: int = 1):
return image._new(image.im.box_blur((radius, radius), n))


def assert_image(im, data, delta=0) -> None:
def assert_image(im, data, delta: int = 0) -> None:
it = iter(im.getdata())
for data_row in data:
im_row = [next(it) for _ in range(im.size[0])]
Expand All @@ -37,7 +37,7 @@ def assert_image(im, data, delta=0) -> None:
next(it)


def assert_blur(im, radius, data, passes=1, delta=0) -> None:
def assert_blur(im, radius, data, passes: int = 1, delta: int = 0) -> None:
# check grayscale image
assert_image(box_blur(im, radius, passes), data, delta)
rgba = Image.merge("RGBA", (im, im, im, im))
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_pcx.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_large_count(tmp_path) -> None:
_roundtrip(tmp_path, im)


def _test_buffer_overflow(tmp_path, im, size=1024) -> None:
def _test_buffer_overflow(tmp_path, im, size: int = 1024) -> None:
_last = ImageFile.MAXBLOCK
ImageFile.MAXBLOCK = size
try:
Expand Down
6 changes: 4 additions & 2 deletions Tests/test_image_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ def compare_reduce_with_box(im, factor) -> None:
assert reduced == reference


def compare_reduce_with_reference(im, factor, average_diff=0.4, max_diff=1) -> None:
def compare_reduce_with_reference(
im, factor, average_diff=0.4, max_diff: int = 1
) -> None:
"""Image.reduce() should look very similar to Image.resize(BOX).

A reference image is compiled from a large source area
Expand Down Expand Up @@ -171,7 +173,7 @@ def compare_reduce_with_reference(im, factor, average_diff=0.4, max_diff=1) -> N
assert_compare_images(reduced, reference, average_diff, max_diff)


def assert_compare_images(a, b, max_average_diff, max_diff=255) -> None:
def assert_compare_images(a, b, max_average_diff, max_diff: int = 255) -> None:
assert a.mode == b.mode, f"got mode {repr(a.mode)}, expected {repr(b.mode)}"
assert a.size == b.size, f"got size {repr(a.size)}, expected {repr(b.size)}"

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_imagecms.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def test_extended_information() -> None:
o = ImageCms.getOpenProfile(SRGB)
p = o.profile

def assert_truncated_tuple_equal(tup1, tup2, digits=10) -> None:
def assert_truncated_tuple_equal(tup1, tup2, digits: int = 10) -> None:
# Helper function to reduce precision of tuples of floats
# recursively and then check equality.
power = 10**digits
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


def test_numpy_to_image() -> None:
def to_image(dtype, bands=1, boolean=0):
def to_image(dtype, bands: int = 1, boolean: int = 0):
if bands == 1:
if boolean:
data = [0, 255] * 50
Expand Down