{"record":{"id":"150629661a872b91","repo":"facebookresearch/detectron2","slug":"unsupported-type-for-argument-serailzie-serial","errorCode":null,"errorMessage":"Unsupported type for argument `serailzie`: {serialize}","messagePattern":"Unsupported type for argument `serailzie`: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"detectron2/data/common.py","lineNumber":229,"sourceCode":"        self,\n        lst: list,\n        copy: bool = True,\n        serialize: Union[bool, Callable] = True,\n    ):\n        \"\"\"\n        Args:\n            lst (list): a list which contains elements to produce.\n            copy (bool): whether to deepcopy the element when producing it,\n                so that the result can be modified in place without affecting the\n                source in the list.\n            serialize (bool or callable): whether to serialize the stroage to other\n                backend. If `True`, the default serialize method will be used, if given\n                a callable, the callable will be used as serialize method.\n        \"\"\"\n        self._lst = lst\n        self._copy = copy\n        if not isinstance(serialize, (bool, Callable)):\n            raise TypeError(f\"Unsupported type for argument `serailzie`: {serialize}\")\n        self._serialize = serialize is not False\n\n        if self._serialize:\n            serialize_method = (\n                serialize\n                if isinstance(serialize, Callable)\n                else _DEFAULT_DATASET_FROM_LIST_SERIALIZE_METHOD\n            )\n            logger.info(f\"Serializing the dataset using: {serialize_method}\")\n            self._lst = serialize_method(self._lst)\n\n    def __len__(self):\n        return len(self._lst)\n\n    def __getitem__(self, idx):\n        if self._copy and not self._serialize:\n            return copy.deepcopy(self._lst[idx])\n        else:","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/facebookresearch/detectron2/blob/a2f4a8771ab77e8411c26b27f24f9489a28a2453/detectron2/data/common.py#L211-L247","documentation":"Raised by SerializeList's __init__ when the `serialize` argument is neither a bool nor a callable. The class uses `serialize` to decide whether to serialize list elements (and optionally accepts a custom serializer callable); any other type (e.g. a string like 'w' or an int) is rejected.","triggerScenarios":"Constructing SerializeList(lst, serialize=<non-bool-non-callable>) e.g. SerializeList(data, serialize='w') or serialize=1; typically hit when passing an open-mode-like string or file object where a bool/callable was expected, or when a variable of the wrong type is forwarded from user config.","commonSituations":"Copy-pasting a torch.utils.data style API where an argument like a file mode string is accepted; passing a serialization function object that is actually None or a string; version changes where the constructor signature changed.","solutions":["Pass a bool: SerializeList(lst, serialize=True) or serialize=False","Or pass a callable used as the serialize method, e.g. SerializeList(lst, serialize=pickle.dumps)","If forwarding a config value, validate it before constructing: assert isinstance(cfg.serialize, (bool, Callable))"],"exampleFix":"// before\nsrl = SerializeList(lst, serialize='w')\n// after\nsrl = SerializeList(lst, serialize=True)","handlingStrategy":"type-guard","validationCode":"from typing import Callable\nassert serialize is None or isinstance(serialize, (bool, Callable)), \\\n    f\"serialize must be bool or Callable, got {type(serialize)}\"","typeGuard":"def is_valid_serialize(x) -> bool:\n    return isinstance(x, bool) or callable(x)","tryCatchPattern":null,"preventionTips":["Validate the serialize argument at config-parse time","Never pass file-mode strings; this API accepts only bool or callable"],"tags":["detectron2","typeerror","argument-validation","serialization"],"backgroundTag":"invalid-argument-type","analyzedSha":"a2f4a8771ab77e8411c26b27f24f9489a28a2453","analyzedAt":"2026-08-27T12:08:21.260Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}