-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Bug Description
When installing cachekit without pyarrow, importing the package fails:
ImportError: pyarrow is not installed. ArrowSerializer requires the [data] extra: pip install 'cachekit[data]'
Root Cause
cachekit/serializers/__init__.py line 7 unconditionally imports ArrowSerializer:
from .arrow_serializer import ArrowSerializerBut pyarrow is not in the required dependencies - it's supposed to be optional.
Expected Behavior
import cachekit should work without pyarrow installed. ArrowSerializer should be lazily imported or guarded.
Reproduction
pip install cachekit # or uv add cachekit
python -c "from cachekit import cache"
# ImportError: pyarrow is not installed...Environment
- cachekit version: 0.3.0
- Python: 3.13
- OS: Linux
Suggested Fix
Option 1: Lazy import in __init__.py:
def __getattr__(name):
if name == "ArrowSerializer":
from .arrow_serializer import ArrowSerializer
return ArrowSerializer
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")Option 2: Guard with try/except:
try:
from .arrow_serializer import ArrowSerializer
except ImportError:
ArrowSerializer = None # type: ignoreOption 3: Add pyarrow to required deps (not recommended - adds 150MB).
Metadata
Metadata
Assignees
Labels
No labels