refactor(core): simplify `_get_least_recently_used_item()` typing
What changed, and why it matters
This is a minor code cleanup that changes how a helper function's input type is described. It makes no functional change to what the code does and does not affect security.
No security action needed; this is a non-functional typing refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors the type annotation of _get_least_recently_used_item() in core/src/storage/cache_thp.py from a union of two list types to a single Sequence[ThpDataCache]. It also adds from typing import Sequence and a trailing pass so that the frozen module generator strips the import correctly. The function body is unchanged.
Changed components
core/src/storage/cache_thp.pyInspect captured patch +2 / −3
diff --git a/core/src/storage/cache_thp.py b/core/src/storage/cache_thp.py
index 2af7db6ad..6d68c8373 100644
--- a/core/src/storage/cache_thp.py
+++ b/core/src/storage/cache_thp.py
@@ -1,5 +1,6 @@
import builtins
from micropython import const
+from typing import Sequence
from storage.cache_common import (
CHANNEL_HOST_STATIC_PUBKEY,
@@ -345,9 +346,7 @@ def _is_cid_unique() -> bool:
return True
-def _get_least_recently_used_item(
- list: list[ChannelCache] | list[SessionThpCache], max_count: int
-) -> int:
+def _get_least_recently_used_item(list: Sequence[ThpDataCache], max_count: int) -> int:
global _usage_counter
lru_counter = _usage_counter + 1
lru_item_index = 0
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.