microsoft/qlib · error · TypeError
update expected at most 1 arguments, got {len(args)}
Error message
update expected at most 1 arguments, got {len(args)} What it means
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.
Source
Thrown at qlib/data/storage/file_storage.py:263
def __setitem__(self, k: InstKT, v: InstVT) -> None:
inst = self._read_instrument()
inst[k] = v
self._write_instrument(inst)
def __delitem__(self, k: InstKT) -> None:
self.check()
inst = self._read_instrument()
del inst[k]
self._write_instrument(inst)
def __getitem__(self, k: InstKT) -> InstVT:
self.check()
return self._read_instrument()[k]
def update(self, *args, **kwargs) -> None:
if len(args) > 1:
raise TypeError(f"update expected at most 1 arguments, got {len(args)}")
inst = self._read_instrument()
if args:
other = args[0] # type: dict
if isinstance(other, Mapping):
for key in other:
inst[key] = other[key]
elif hasattr(other, "keys"):
for key in other.keys():
inst[key] = other[key]
else:
for key, value in other:
inst[key] = value
for key, value in kwargs.items():
inst[key] = value
self._write_instrument(inst)
def __len__(self) -> int:View on GitHub (pinned to 79633dd950)
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.
Example fix
# before
inst_storage.update(dict_a, dict_b) # TypeError
# after
inst_storage.update({**dict_a, **dict_b})
# or
inst_storage.update(dict_a)
inst_storage.update(dict_b) Defensive patterns
Strategy: validation
Validate before calling
if len(args) > 1:
merged = {}
for d in args:
merged.update(d)
args = (merged,) Prevention
- Follow dict.update semantics: one positional mapping plus kwargs.
- In generic wrappers, merge dicts before calling update.
When it happens
Trigger: 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.
Common situations: Generic dict-like wrapper code forwarding *args into update; scripts that merged multiple instrument files by calling update(a, b) in one call.
Related errors
- Unsupported filter types: {type(filter_t)}! Filter only supp
- This type of `limit_threshold` is not supported
- stock data from resam_ts_data must be a number, pd.Series or
- provider_uri does not support {type(provider_uri)}
- Unsupported data type: {type(data)}.
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/b61423c42402440b.
Report an issue: GitHub.