From 594e9dc441442c7ba9ef73adea7f9b134758c97d Mon Sep 17 00:00:00 2001 From: the-forest-tree Date: Thu, 9 Nov 2023 11:19:50 +0000 Subject: [PATCH] fix: delay import of PIL to avoid ModuleNotFoundError when using the package in no-dev mode --- src/hrflow_connectors/core/connector.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hrflow_connectors/core/connector.py b/src/hrflow_connectors/core/connector.py index 2feb59449..6d41fa487 100644 --- a/src/hrflow_connectors/core/connector.py +++ b/src/hrflow_connectors/core/connector.py @@ -13,7 +13,6 @@ from functools import partial from pathlib import Path -from PIL import Image, UnidentifiedImageError from pydantic import ( BaseModel, Field, @@ -766,6 +765,13 @@ class ConnectorModel(BaseModel): actions: t.List[ConnectorAction] def logo(self, connectors_directory: Path) -> str: + try: + from PIL import Image, UnidentifiedImageError + except ModuleNotFoundError: # pragma: no cover + raise Exception( + "PIL is not found in current environment. Mind that you need to install" + " the package with dev dependencies to use manifest utility" + ) connector_directory = connectors_directory / self.name.lower() if not connector_directory.is_dir(): raise ValueError(