{"record":{"id":"7aa3c27ff8752a13","repo":"microsoft/qlib","slug":"subclass-of-featurestorage-must-implement-getit","errorCode":null,"errorMessage":"Subclass of FeatureStorage must implement `__getitem__(s: slice)` method","messagePattern":"Subclass of FeatureStorage must implement `__getitem__\\(s: slice\\)` method","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/data/storage/storage.py","lineNumber":70,"sourceCode":"class UserFeatureStorage(FeatureStorage):\n\n    def __getitem__(self, s: slice) -> pd.Series:\n        '''x.__getitem__(slice(start: int, stop: int, step: int)) <==> x[start:stop:step]\n\n        Returns\n        -------\n            pd.Series(values, index=pd.RangeIndex(start, len(values))\n\n        Notes\n        -------\n        if data(storage) does not exist:\n            if isinstance(i, int):\n                return (None, None)\n            if isinstance(i,  slice):\n                # return empty pd.Series\n                return pd.Series(dtype=np.float32)\n        '''\n        raise NotImplementedError(\n            \"Subclass of FeatureStorage must implement `__getitem__(s: slice)` method\"\n        )\n\n\n\"\"\"\n\n\nclass BaseStorage:\n    @property\n    def storage_name(self) -> str:\n        return re.findall(\"[A-Z][^A-Z]*\", self.__class__.__name__)[-2].lower()\n\n\nclass CalendarStorage(BaseStorage):\n    \"\"\"\n    The behavior of CalendarStorage's methods and List's methods of the same name remain consistent\n    \"\"\"\n","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/storage/storage.py#L52-L88","documentation":"Error \"Subclass of FeatureStorage must implement `__getitem__(s: slice)` method\" thrown in microsoft/qlib.","triggerScenarios":"This error is raised at qlib/data/storage/storage.py:70 when the guard condition fails: \"Subclass of FeatureStorage must implement `__getitem__(s: slice)` 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__(s: slice)` in your FeatureStorage subclass.","Use the built-in FileFeatureStorage 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"}