{"record":{"id":"b61423c42402440b","repo":"microsoft/qlib","slug":"update-expected-at-most-1-arguments-got-len-args","errorCode":null,"errorMessage":"update expected at most 1 arguments, got {len(args)}","messagePattern":"update expected at most 1 arguments, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"qlib/data/storage/file_storage.py","lineNumber":263,"sourceCode":"\n    def __setitem__(self, k: InstKT, v: InstVT) -> None:\n        inst = self._read_instrument()\n        inst[k] = v\n        self._write_instrument(inst)\n\n    def __delitem__(self, k: InstKT) -> None:\n        self.check()\n        inst = self._read_instrument()\n        del inst[k]\n        self._write_instrument(inst)\n\n    def __getitem__(self, k: InstKT) -> InstVT:\n        self.check()\n        return self._read_instrument()[k]\n\n    def update(self, *args, **kwargs) -> None:\n        if len(args) > 1:\n            raise TypeError(f\"update expected at most 1 arguments, got {len(args)}\")\n        inst = self._read_instrument()\n        if args:\n            other = args[0]  # type: dict\n            if isinstance(other, Mapping):\n                for key in other:\n                    inst[key] = other[key]\n            elif hasattr(other, \"keys\"):\n                for key in other.keys():\n                    inst[key] = other[key]\n            else:\n                for key, value in other:\n                    inst[key] = value\n        for key, value in kwargs.items():\n            inst[key] = value\n\n        self._write_instrument(inst)\n\n    def __len__(self) -> int:","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/storage/file_storage.py#L245-L281","documentation":"Raised by FileInstrumentStorage.update (qlib/data/storage/file_storage.py), which mirrors dict.update semantics: it accepts at most one positional argument (plus keyword updates). Passing two or more positional args (update(d1, d2)) exceeds the supported signature and raises TypeError, matching dict.update's own 'expected at most 1 argument' behavior.","triggerScenarios":"Calling instruments_storage.update(other_dict, another_dict); delegating to update(*args) from wrapper code that forwards multiple positional dicts; porting code that assumed a merge(expected, actual) style signature.","commonSituations":"Generic dict-like wrapper code forwarding *args into update; scripts that merged multiple instrument files by calling update(a, b) in one call.","solutions":["Call update once per mapping: update(a); update(b), or pre-merge with {**a, **b} and pass one dict.","Use keyword form where appropriate: update(SH600000=(start, end)).","Audit wrapper code that forwards *args into update and pass a single dict positionally."],"exampleFix":"# before\ninst_storage.update(dict_a, dict_b)  # TypeError\n\n# after\ninst_storage.update({**dict_a, **dict_b})\n# or\ninst_storage.update(dict_a)\ninst_storage.update(dict_b)","handlingStrategy":"validation","validationCode":"if len(args) > 1:\n    merged = {}\n    for d in args:\n        merged.update(d)\n    args = (merged,)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Follow dict.update semantics: one positional mapping plus kwargs.","In generic wrappers, merge dicts before calling update."],"tags":["qlib","instruments","dict-api","type-error"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}