diff --git a/pyproject.toml b/pyproject.toml index 1ad21a1d4f68..4a2951f65326 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,6 @@ module = [ "machine.*", "task.*", "testvm", - "PIL", # run with bots checked out but its dependencies missing "libvirt", diff --git a/test/common/testlib.py b/test/common/testlib.py index 6758b2641e53..4e6f9a525406 100644 --- a/test/common/testlib.py +++ b/test/common/testlib.py @@ -42,11 +42,7 @@ from lcov import write_lcov from lib.constants import OSTREE_IMAGES from machine import testvm - -try: - from PIL import Image -except ImportError: - Image = None +from PIL import Image _T = TypeVar('_T') _FT = TypeVar("_FT", bound=Callable[..., Any]) @@ -1203,12 +1199,13 @@ def ignorable_coord(x: int, y: int) -> bool: def ignorable_change(a: tuple[int, int, int], b: tuple[int, int, int]) -> bool: return abs(a[0] - b[0]) <= 2 and abs(a[1] - b[1]) <= 2 and abs(a[2] - b[2]) <= 2 - def img_eq(ref: Image, now: Image, delta: Image) -> bool: + def img_eq(ref: Image.Image, now: Image.Image, delta: Image.Image) -> bool: # This is slow but exactly what we want. # ImageMath might be able to speed this up. - data_ref = ref.load() - data_now = now.load() - data_delta = delta.load() + # no-untyped-call: see https://github.com/python-pillow/Pillow/issues/8029 + data_ref = ref.load() # type: ignore[no-untyped-call] + data_now = now.load() # type: ignore[no-untyped-call] + data_delta = delta.load() # type: ignore[no-untyped-call] result = True count = 0 width, height = delta.size @@ -1233,7 +1230,7 @@ def img_eq(ref: Image, now: Image, delta: Image) -> bool: # Preserve alpha channel so that the 'now' # image can be used as the new reference image # without further changes - img_now.putalpha(img_ref.getchannel("A")) + img_now.putalpha(img_ref.getchannel("A")) # type: ignore[no-untyped-call] img_now.save(filename) attach(filename, move=True) ref_filename_for_attach = base + "-reference.png"