Skip to content

Commit bd25eda

Browse files
committed
fix: resolve all mypy type checking errors
- Fix type conversion issues in config.py environment variable handling - Add proper type annotations for dictionaries in config saving - Fix type annotation for fuzzy search results list in cache.py - Resolve search_keys type inconsistency (set vs list) in fuzzy search - Add proper type annotations for key_data dictionaries in decorators.py and cli.py - All mypy errors now resolved with proper type safety maintained
1 parent 51d30b3 commit bd25eda

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

src/yokedcache/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
database integration.
77
"""
88

9-
__version__ = "0.1.1"
9+
__version__ = "0.1.2"
1010
__author__ = "Project Yoked LLC"
1111
__email__ = "twogoodgamer2@gmail.com"
1212
__license__ = "MIT"

src/yokedcache/cache.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,18 +488,19 @@ async def fuzzy_search(
488488
logger.error("fuzzywuzzy library not available for fuzzy search")
489489
return []
490490

491-
results = []
491+
results: List[FuzzySearchResult] = []
492492

493493
try:
494494
async with self._get_redis() as r:
495495
# Get keys to search
496496
if tags:
497497
# Search within tagged keys
498-
search_keys = set()
498+
search_keys_set = set()
499499
for tag in tags:
500500
tag_key = self._build_tag_key(tag)
501501
tag_keys = await r.smembers(tag_key)
502-
search_keys.update(tag_keys)
502+
search_keys_set.update(tag_keys)
503+
search_keys = list(search_keys_set)
503504
else:
504505
# Search all keys with our prefix
505506
pattern = self._build_key("*")

src/yokedcache/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ async def export_config(ctx, output: Optional[str]):
455455
)
456456

457457
try:
458-
config_dict = {
458+
config_dict: Dict[str, Any] = {
459459
"redis_url": cache.config.redis_url,
460460
"default_ttl": cache.config.default_ttl,
461461
"key_prefix": cache.config.key_prefix,

src/yokedcache/config.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,20 @@ def _apply_env_overrides(self) -> None:
105105
}
106106

107107
for env_var, attr_name in env_mappings.items():
108-
env_value = os.getenv(env_var)
109-
if env_value is not None:
108+
env_str = os.getenv(env_var)
109+
if env_str is not None:
110110
# Type conversion based on current attribute type
111111
current_value = getattr(self, attr_name)
112112
if isinstance(current_value, bool):
113-
env_value = env_value.lower() in ("true", "1", "yes", "on")
113+
converted_value = env_str.lower() in ("true", "1", "yes", "on")
114114
elif isinstance(current_value, int):
115-
env_value = int(env_value)
115+
converted_value = int(env_str)
116116
elif isinstance(current_value, float):
117-
env_value = float(env_value)
117+
converted_value = float(env_str)
118+
else:
119+
converted_value = env_str
118120

119-
setattr(self, attr_name, env_value)
121+
setattr(self, attr_name, converted_value)
120122

121123
def _validate_config(self) -> None:
122124
"""Validate configuration values."""
@@ -342,7 +344,7 @@ def save_config_to_file(config: CacheConfig, file_path: Union[str, Path]) -> Non
342344
file_path = Path(file_path)
343345

344346
# Convert config to dictionary format suitable for YAML
345-
config_dict = {
347+
config_dict: Dict[str, Any] = {
346348
"redis_url": config.redis_url,
347349
"default_ttl": config.default_ttl,
348350
"key_prefix": config.key_prefix,

src/yokedcache/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def _build_function_cache_key(
443443
bound_args.apply_defaults()
444444

445445
# Create hashable representation
446-
key_data = {
446+
key_data: Dict[str, Any] = {
447447
"function": f"{func.__module__}.{func.__name__}",
448448
"args": {},
449449
}

0 commit comments

Comments
 (0)