Commit 7dd8597
committed
fix: fail-fast import guard for ArrowSerializer when pyarrow missing
The import guard in auto_serializer.py was ineffective because
ArrowSerializer class was always defined and importable - the
ImportError only fired in __init__(), after the guard had passed.
Fix: Raise ImportError at module level when pyarrow isn't installed,
so the import guard actually catches it:
Before (broken):
auto_serializer.py: from .arrow_serializer import ArrowSerializer ✓
auto_serializer.py: HAS_ARROW_SERIALIZER = True # Wrong!
ArrowSerializer.__init__(): raise ImportError # Too late
After (fixed):
arrow_serializer.py: import pyarrow → ImportError
auto_serializer.py: from .arrow_serializer... → ImportError caught
auto_serializer.py: HAS_ARROW_SERIALIZER = False # Correct!
Adds test coverage for the import guard by mocking pyarrow unavailability.1 parent bc80fe9 commit 7dd8597
File tree
2 files changed
+54
-13
lines changed- src/cachekit/serializers
- tests/unit
2 files changed
+54
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 46 | + | |
| 47 | + | |
50 | 48 | | |
51 | 49 | | |
52 | 50 | | |
| |||
124 | 122 | | |
125 | 123 | | |
126 | 124 | | |
127 | | - | |
128 | 125 | | |
129 | 126 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | 127 | | |
135 | 128 | | |
136 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
0 commit comments