[mypy][6/N] Fix all the core subdirectory typing (#4450)

Co-authored-by: Cade Daniel <edacih@gmail.com>
This commit is contained in:
SangBin Cho
2024-05-02 03:01:00 +00:00
committed by GitHub
co-authored by Cade Daniel
parent 5e401bce17
commit cf8cac8c70
10 changed files with 275 additions and 83 deletions
+10 -5
View File
@@ -32,15 +32,20 @@ class Evictor(ABC):
@abstractmethod
def add(self, block_id: int, content_hash: int, num_hashed_tokens: int,
last_accessed: int):
last_accessed: float):
"""Adds block to the evictor, making it a candidate for eviction"""
pass
@abstractmethod
def update(self, block_id: int, last_accessed: int):
def update(self, block_id: int, last_accessed: float):
"""Update corresponding block's access time in metadata"""
pass
@abstractmethod
def remove(self, block_id: int):
"""Remove a given block id from the cache."""
pass
@abstractproperty
def num_blocks(self) -> int:
pass
@@ -55,7 +60,7 @@ class BlockMetaData():
"""
def __init__(self, content_hash: int, num_hashed_tokens: int,
last_accessed: int):
last_accessed: float):
self.content_hash = content_hash
self.num_hashed_tokens = num_hashed_tokens
self.last_accessed = last_accessed
@@ -96,12 +101,12 @@ class LRUEvictor(Evictor):
return evicted_block_id, evicted_block.content_hash
def add(self, block_id: int, content_hash: int, num_hashed_tokens: int,
last_accessed: int):
last_accessed: float):
self.free_table[block_id] = BlockMetaData(content_hash,
num_hashed_tokens,
last_accessed)
def update(self, block_id: int, last_accessed: int):
def update(self, block_id: int, last_accessed: float):
self.free_table[block_id].last_accessed = last_accessed
def remove(self, block_id: int):