77import sys
88from io import BytesIO
99from pathlib import Path
10- from typing import Any
10+ from typing import Any , Literal , cast
1111
1212import pytest
1313
@@ -209,13 +209,13 @@ def test_exceptions() -> None:
209209 ImageCms .buildTransform ("foo" , "bar" , "RGB" , "RGB" )
210210
211211 with pytest .raises (ImageCms .PyCMSError , match = "Invalid type for Profile" ):
212- ImageCms .getProfileName (None )
212+ ImageCms .getProfileName (None ) # type: ignore[arg-type]
213213 skip_missing ()
214214
215215 # Python <= 3.9: "an integer is required (got type NoneType)"
216216 # Python > 3.9: "'NoneType' object cannot be interpreted as an integer"
217217 with pytest .raises (ImageCms .PyCMSError , match = "integer" ):
218- ImageCms .isIntentSupported (SRGB , None , None )
218+ ImageCms .isIntentSupported (SRGB , None , None ) # type: ignore[arg-type]
219219
220220
221221def test_display_profile () -> None :
@@ -239,7 +239,7 @@ def test_unsupported_color_space() -> None:
239239 "Color space not supported for on-the-fly profile creation (unsupported)"
240240 ),
241241 ):
242- ImageCms .createProfile ("unsupported" )
242+ ImageCms .createProfile ("unsupported" ) # type: ignore[arg-type]
243243
244244
245245def test_invalid_color_temperature () -> None :
@@ -352,7 +352,7 @@ def test_extended_information() -> None:
352352 p = o .profile
353353
354354 def assert_truncated_tuple_equal (
355- tup1 : tuple [Any , ...], tup2 : tuple [Any , ...], digits : int = 10
355+ tup1 : tuple [Any , ...] | None , tup2 : tuple [Any , ...], digits : int = 10
356356 ) -> None :
357357 # Helper function to reduce precision of tuples of floats
358358 # recursively and then check equality.
@@ -368,6 +368,7 @@ def truncate_tuple(tuple_value: tuple[Any, ...]) -> tuple[Any, ...]:
368368 for val in tuple_value
369369 )
370370
371+ assert tup1 is not None
371372 assert truncate_tuple (tup1 ) == truncate_tuple (tup2 )
372373
373374 assert p .attributes == 4294967296
@@ -513,22 +514,22 @@ def test_non_ascii_path(tmp_path: Path) -> None:
513514def test_profile_typesafety () -> None :
514515 # does not segfault
515516 with pytest .raises (TypeError , match = "Invalid type for Profile" ):
516- ImageCms .ImageCmsProfile (0 ). tobytes ()
517+ ImageCms .ImageCmsProfile (0 ) # type: ignore[arg-type]
517518 with pytest .raises (TypeError , match = "Invalid type for Profile" ):
518- ImageCms .ImageCmsProfile (1 ). tobytes ()
519+ ImageCms .ImageCmsProfile (1 ) # type: ignore[arg-type]
519520
520521 # also check core function
521522 with pytest .raises (TypeError ):
522- ImageCms .core .profile_tobytes (0 )
523+ ImageCms .core .profile_tobytes (0 ) # type: ignore[arg-type]
523524 with pytest .raises (TypeError ):
524- ImageCms .core .profile_tobytes (1 )
525+ ImageCms .core .profile_tobytes (1 ) # type: ignore[arg-type]
525526
526527 if not is_pypy ():
527528 # core profile should not be directly instantiable
528529 with pytest .raises (TypeError ):
529530 ImageCms .core .CmsProfile ()
530531 with pytest .raises (TypeError ):
531- ImageCms .core .CmsProfile (0 )
532+ ImageCms .core .CmsProfile (0 ) # type: ignore[call-arg]
532533
533534
534535@pytest .mark .skipif (is_pypy (), reason = "fails on PyPy" )
@@ -537,7 +538,7 @@ def test_transform_typesafety() -> None:
537538 with pytest .raises (TypeError ):
538539 ImageCms .core .CmsTransform ()
539540 with pytest .raises (TypeError ):
540- ImageCms .core .CmsTransform (0 )
541+ ImageCms .core .CmsTransform (0 ) # type: ignore[call-arg]
541542
542543
543544def assert_aux_channel_preserved (
@@ -637,7 +638,8 @@ def test_auxiliary_channels_isolated() -> None:
637638 continue
638639
639640 # convert with and without AUX data, test colors are equal
640- source_profile = ImageCms .createProfile (src_format [1 ])
641+ src_colorSpace = cast (Literal ["LAB" , "XYZ" , "sRGB" ], src_format [1 ])
642+ source_profile = ImageCms .createProfile (src_colorSpace )
641643 destination_profile = ImageCms .createProfile (dst_format [1 ])
642644 source_image = src_format [3 ]
643645 test_transform = ImageCms .buildTransform (
0 commit comments