Fixed type hints

This commit is contained in:
Andrew Murray 2025-05-07 23:29:54 +10:00
parent 36640de607
commit 7125fe4096
3 changed files with 21 additions and 22 deletions

View File

@ -45,7 +45,9 @@ class TestFileJpegXl:
def test_version(self) -> None:
_jpegxl.JpegXlDecoderVersion()
assert re.search(r"\d+\.\d+\.\d+$", features.version_module("jpegxl"))
version = features.version_module("jpegxl")
assert version is not None
assert re.search(r"\d+\.\d+\.\d+$", version)
def test_read_rgb(self) -> None:
"""

View File

@ -29,8 +29,7 @@ except ImportError:
def test_read_exif_metadata() -> None:
file_path = "Tests/images/flower.jxl"
with Image.open(file_path) as image:
with Image.open("Tests/images/flower.jxl") as image:
assert image.format == "JPEG XL"
exif_data = image.info.get("exif", None)
assert exif_data
@ -57,8 +56,7 @@ def test_read_exif_metadata_without_prefix() -> None:
def test_read_icc_profile() -> None:
file_path = "Tests/images/flower2.jxl"
with Image.open(file_path) as image:
with Image.open("Tests/images/flower2.jxl") as image:
assert image.format == "JPEG XL"
assert image.info.get("icc_profile", None)
@ -110,7 +108,7 @@ def test_4_byte_exif(monkeypatch: pytest.MonkeyPatch) -> None:
def get_icc(self) -> None:
pass
def get_exif(self) -> None:
def get_exif(self) -> bytes:
return b"\0\0\0\0"
def get_xmp(self) -> None:

View File

@ -753,7 +753,7 @@ class pil_build_ext(build_ext):
self, "jxl/decode.h"
):
if _find_library_file(self, "jxl"):
feature.set("jpegxl", "jxl jxl_threads")
feature.set("jpegxl", "jxl")
if feature.want("imagequant"):
_dbg("Looking for imagequant")
@ -838,15 +838,6 @@ class pil_build_ext(build_ext):
# alternate Windows name.
feature.set("lcms", "lcms2_static")
if feature.get("jpegxl"):
# jxl and jxl_threads are required
libs = feature.get("jpegxl").split()
defs = []
self._update_extension("PIL._jpegxl", libs, defs)
else:
self._remove_extension("PIL._jpegxl")
if feature.want("webp"):
_dbg("Looking for webp")
if all(
@ -970,6 +961,14 @@ class pil_build_ext(build_ext):
else:
self._remove_extension("PIL._avif")
jpegxl = feature.get("jpegxl")
if isinstance(jpegxl, str):
# jxl and jxl_threads are required
libs = [jpegxl, jpegxl + "_threads"]
self._update_extension("PIL._jpegxl", libs)
else:
self._remove_extension("PIL._jpegxl")
tk_libs = ["psapi"] if sys.platform in ("win32", "cygwin") else []
self._update_extension("PIL._imagingtk", tk_libs)