Conditionally define type hint to avoid requiring core

This commit is contained in:
Andrew Murray 2024-07-03 21:05:48 +10:00
parent 51bd7d2ea8
commit a34ac045c3

View File

@ -31,6 +31,10 @@ from ._typing import SupportsRead
try:
from . import _imagingcms as core
_CmsProfileCompatible = Union[
str, SupportsRead[bytes], core.CmsProfile, "ImageCmsProfile"
]
except ImportError as ex:
# Allow error import for doc purposes, but error out when accessing
# anything in core.
@ -391,10 +395,6 @@ def get_display_profile(handle: SupportsInt | None = None) -> ImageCmsProfile |
# pyCMS compatible layer
# --------------------------------------------------------------------.
_CmsProfileCompatible = Union[
str, SupportsRead[bytes], core.CmsProfile, ImageCmsProfile
]
class PyCMSError(Exception):
"""(pyCMS) Exception class.