Skip to content

Commit 23f7fef

Browse files
Refactor CMAB cache type hints for improved clarity and type safety
1 parent 3d970fc commit 23f7fef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

optimizely/optimizely_factory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from .optimizely import Optimizely
2525
from .odp.lru_cache import LRUCache
2626
from .cmab.cmab_client import DefaultCmabClient, CmabRetryConfig
27-
from .cmab.cmab_service import DefaultCmabService, DEFAULT_CMAB_CACHE_TIMEOUT, DEFAULT_CMAB_CACHE_SIZE
27+
from .cmab.cmab_service import DefaultCmabService, CmabCacheValue, DEFAULT_CMAB_CACHE_TIMEOUT, DEFAULT_CMAB_CACHE_SIZE
2828

2929
if TYPE_CHECKING:
3030
# prevent circular dependenacy by skipping import at runtime
@@ -41,7 +41,7 @@ class OptimizelyFactory:
4141
blocking_timeout: Optional[int] = None
4242
cmab_cache_size: Optional[int] = None
4343
cmab_cache_ttl: Optional[int] = None
44-
cmab_custom_cache: Optional[LRUCache] = None
44+
cmab_custom_cache: Optional[LRUCache[str, CmabCacheValue]] = None
4545

4646
@staticmethod
4747
def set_batch_size(batch_size: int) -> int:
@@ -118,7 +118,7 @@ def set_cmab_cache_ttl(cache_ttl: int, logger: Optional[optimizely_logger.Logger
118118
return OptimizelyFactory.cmab_cache_ttl
119119

120120
@staticmethod
121-
def set_cmab_custom_cache(custom_cache: LRUCache) -> LRUCache:
121+
def set_cmab_custom_cache(custom_cache: LRUCache[str, CmabCacheValue]) -> LRUCache:
122122
""" Convenience method for setting custom CMAB cache.
123123
Args:
124124
custom_cache: Cache implementation with lookup, save, remove, and reset methods.

0 commit comments

Comments
 (0)