{"record":{"id":"afe5816f1a326387","repo":"microsoft/qlib","slug":"subclass-of-calendarstorage-must-implement-geti","errorCode":null,"errorMessage":"Subclass of CalendarStorage must implement `__getitem__(i: int)`/`__getitem__(s: slice)`  method","messagePattern":"Subclass of CalendarStorage must implement `__getitem__\\(i: int\\)`/`__getitem__\\(s: slice\\)`  method","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/data/storage/storage.py","lineNumber":175,"sourceCode":"\n    @overload\n    def __getitem__(self, s: slice) -> Iterable[CalVT]:\n        \"\"\"x.__getitem__(slice(start: int, stop: int, step: int)) <==> x[start:stop:step]\"\"\"\n\n    @overload\n    def __getitem__(self, i: int) -> CalVT:\n        \"\"\"x.__getitem__(i) <==> x[i]\"\"\"\n\n    def __getitem__(self, i) -> CalVT:\n        \"\"\"\n\n        Raises\n        ------\n        ValueError\n            If the data(storage) does not exist, raise ValueError\n\n        \"\"\"\n        raise NotImplementedError(\n            \"Subclass of CalendarStorage must implement `__getitem__(i: int)`/`__getitem__(s: slice)`  method\"\n        )\n\n    def __len__(self) -> int:\n        \"\"\"\n\n        Raises\n        ------\n        ValueError\n            If the data(storage) does not exist, raise ValueError\n\n        \"\"\"\n        raise NotImplementedError(\"Subclass of CalendarStorage must implement `__len__`  method\")\n\n\nclass InstrumentStorage(BaseStorage):\n    def __init__(self, market: str, freq: str, **kwargs):\n        self.market = market","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/storage/storage.py#L157-L193","documentation":"Error \"Subclass of CalendarStorage must implement `__getitem__(i: int)`/`__getitem__(s: slice)`  method\" thrown in microsoft/qlib.","triggerScenarios":"This error is raised at qlib/data/storage/storage.py:175 when the guard condition fails: \"Subclass of CalendarStorage must implement `__getitem__` method\". It triggers when the code path receives input or a state that violates the precondition checked at this point — e.g. an unimplemented abstract method being called, an unsupported argument type/value, or an invalid configuration. To avoid it, satisfy the documented precondition before this call: implement the required method in your subclass, or pass a supported value of the expected type as described by the message.","commonSituations":"See trigger scenarios.","solutions":["Implement `__getitem__` (both int and slice forms) in your CalendarStorage subclass.","Use the built-in FileCalendarStorage which implements `__getitem__`."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}