Skip to content

Commit

Permalink
fix: delay import of PIL to avoid ModuleNotFoundError when using the …
Browse files Browse the repository at this point in the history
…package in no-dev mode
  • Loading branch information
the-forest-tree authored and the-forest-tree committed Nov 9, 2023
1 parent 20c4377 commit 594e9dc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/hrflow_connectors/core/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from functools import partial
from pathlib import Path

from PIL import Image, UnidentifiedImageError
from pydantic import (
BaseModel,
Field,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 594e9dc

Please sign in to comment.