Skip to content

Conversation

@27Bslash6
Copy link
Contributor

Summary

  • Fixes unconditional ArrowSerializer import that broke users without pyarrow
  • Implements lazy loading via _get_arrow_serializer() helper
  • Adds __getattr__ for lazy attribute access on module
  • Updates benchmark_serializers and get_serializer_info to handle lazy loading

Test plan

  • Verify pip install cachekit works without pyarrow
  • Verify from cachekit import cache succeeds
  • Verify get_serializer('arrow') raises ImportError when pyarrow missing
  • Verify pip install 'cachekit[data]' enables ArrowSerializer

Fixes #41

ArrowSerializer was unconditionally imported at module load time,
causing ImportError for users who install cachekit without the
[data] extra (pyarrow).

Changes:
- Remove top-level ArrowSerializer import
- Add lazy loading via _get_arrow_serializer() helper
- Use __getattr__ for lazy attribute access
- Update SERIALIZER_REGISTRY to use None placeholder
- Fix benchmark_serializers and get_serializer_info to handle
  lazy loading gracefully

Users can now:
- pip install cachekit and use default serializers
- pip install cachekit[data] to enable ArrowSerializer

Fixes #41
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 16 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/cachekit/serializers/__init__.py 27.27% 15 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

- Add 14 unit tests for lazy loading mechanism
- Test _get_arrow_serializer(), __getattr__, get_serializer('arrow')
- Test benchmark_serializers() and get_serializer_info() with lazy loading
- Add unit conftest to skip Redis isolation for pure unit tests
- Include Windows platform.node() fix (cherry-picked from #43)
- Format: whitespace in conftest.py
- CVE: urllib3 2.6.1 → 2.6.3 (GHSA-g4mx-q9vg-27p4)
- Type: add type:ignore for hasattr-guarded get_info() call
@27Bslash6 27Bslash6 merged commit 065eb23 into main Jan 14, 2026
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImportError: ArrowSerializer imported unconditionally but pyarrow not in deps

2 participants