Coverage for paintmaskanimator/optional_deps.py: 55%

11 statements  

« prev     ^ index     » next       coverage.py v7.17.0, created at 2026-11-02 04:50 +0000

1"""Optional third-party dependencies, resolved to ``None`` when unavailable. 

2 

3Pillow and psd_tools are declared under the ``full`` extra: the application runs 

4without them, with the PIL-backed image paths and ``.psd`` import disabled. Every 

5consumer imports the shim from here and checks for ``None`` rather than wrapping 

6its own ``try``/``except ImportError``, so "is this feature available?" has one 

7answer in one place. 

8 

9The *required* dependencies (PySide6, numpy) are checked by 

10``dependency_check.py`` at start-up and imported directly where they are used. 

11""" 

12from __future__ import annotations 

13 

14try: 

15 from PIL import Image as PILImage, ImageFilter as PILImageFilter 

16except (ImportError, OSError): 

17 # Pillow is optional; a missing or broken install disables PIL-backed paths. 

18 PILImage = None 

19 PILImageFilter = None 

20 

21try: 

22 from psd_tools import PSDImage # pyright: ignore[reportMissingImports] 

23except (ImportError, OSError): 

24 # psd_tools is optional; absence disables .psd import only. 

25 PSDImage = None 

26 

27__all__ = ["PILImage", "PILImageFilter", "PSDImage"]