Skip to content

Commit a60050e

Browse files
committed
[Fix] Correct wrong signatures in the type stubs
These are the signatures users see in their IDE, and four were wrong: - `TraceAnalyzer.__init__` declared a leading `analyzer` parameter that does not exist and made `analysis_param`/`analysis_option` required. The real signature is `(reader, output_path, analysis_param=None, analysis_option=None)` per `trace_analyzer.py`. - `TraceReader.__init__` declared `**kwargs`; it actually takes `(trace, trace_type=UNKNOWN_TRACE, reader_init_params=None)`, and exposes `c_reader`, which callers rely on to pick the C fast path. - `Request.op` defaulted to `ReqOp.READ`, which is not a member of the enum. `export_cache.cpp` binds the default as `OP_NOP`. - `CacheBase.set_cache_size` was missing.
1 parent 9da1369 commit a60050e

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

libcachesim/__init__.pyi

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Request:
1818
def __init__(
1919
self,
2020
obj_size: int = 1,
21-
op: ReqOp = ReqOp.READ,
21+
op: ReqOp = ReqOp.OP_NOP,
2222
valid: bool = True,
2323
obj_id: int = 0,
2424
clock_time: int = 0,
@@ -151,6 +151,7 @@ class CacheBase:
151151
def to_evict(self, req: Request) -> CacheObject: ...
152152
def get_occupied_byte(self) -> int: ...
153153
def get_n_obj(self) -> int: ...
154+
def set_cache_size(self, new_size: int) -> None: ...
154155
def print_cache(self) -> str: ...
155156
def process_trace(self, reader: ReaderProtocol, start_req: int = 0, max_req: int = -1) -> tuple[float, float]: ...
156157
@property
@@ -323,7 +324,12 @@ class PluginCache(CacheBase):
323324
# Readers
324325
class TraceReader(ReaderProtocol):
325326
c_reader: bool
326-
def __init__(self, trace: str, trace_type: TraceType = TraceType.UNKNOWN_TRACE, **kwargs): ...
327+
def __init__(
328+
self,
329+
trace: str,
330+
trace_type: TraceType = TraceType.UNKNOWN_TRACE,
331+
reader_init_params: Optional[ReaderInitParam] = None,
332+
): ...
327333

328334
class SyntheticReader(ReaderProtocol):
329335
c_reader: bool
@@ -360,7 +366,13 @@ def create_uniform_requests(
360366

361367
# Analyzer
362368
class TraceAnalyzer:
363-
def __init__(self, analyzer, reader: ReaderProtocol, output_path: str, analysis_param, analysis_option): ...
369+
def __init__(
370+
self,
371+
reader: ReaderProtocol,
372+
output_path: str,
373+
analysis_param: Optional[AnalysisParam] = None,
374+
analysis_option: Optional[AnalysisOption] = None,
375+
): ...
364376
def run(self) -> None: ...
365377
def cleanup(self) -> None: ...
366378

0 commit comments

Comments
 (0)