{"record":{"id":"2bf38c3b30c7f83a","repo":"microsoft/qlib","slug":"this-type-of-input-is-not-supported-2bf38c","errorCode":null,"errorMessage":"This type of input is not supported","messagePattern":"This type of input is not supported","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/utils/mod.py","lineNumber":115,"sourceCode":"            m_path, cls = split_module_path(config[key])\n            if m_path == \"\":\n                m_path = config.get(\"module_path\", default_module)\n            module = get_module_by_module_path(m_path)\n\n            # 2) get callable\n            _callable = getattr(module, cls)  # may raise AttributeError\n        else:\n            _callable = config[key]  # the class type itself is passed in\n        kwargs = config.get(\"kwargs\", {})\n    elif isinstance(config, str):\n        # a.b.c.ClassName\n        m_path, cls = split_module_path(config)\n        module = get_module_by_module_path(default_module if m_path == \"\" else m_path)\n\n        _callable = getattr(module, cls)\n        kwargs = {}\n    else:\n        raise NotImplementedError(f\"This type of input is not supported\")\n    return _callable, kwargs\n\n\nget_cls_kwargs = get_callable_kwargs  # NOTE: this is for compatibility for the previous version\n\n\ndef init_instance_by_config(\n    config: InstConf,\n    default_module=None,\n    accept_types: Union[type, Tuple[type]] = (),\n    try_kwargs: Dict = {},\n    **kwargs,\n) -> Any:\n    \"\"\"\n    get initialized instance with config\n\n    Parameters\n    ----------","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/utils/mod.py#L97-L133","documentation":"qlib.utils.mod.get_callable_kwargs accepts exactly three config shapes for `config`: a str like 'a.b.c.ClassName' (split into module + class), a dict/Mapping with 'class' and optional 'module_path'/'kwargs', or the class type itself (which must be within accept_types for init_instance_by_config). Anything else — int, list, None, tuple — hits the final else and raises NotImplementedError.","triggerScenarios":"init_instance_by_config(['MyClass']) (list instead of dict), init_instance_by_config(123), or passing a Mapping-like object that is not an instance of collections.abc.Mapping (e.g. a JSON string that was never parsed).","commonSituations":"Workflow YAML where a config block is a list of one config rather than the config itself; config loaded from JSON remaining a str; passing a variable that was expected to be a class but is an instance/None; refactors that wrap configs in extra nesting.","solutions":["Pass a dict: {'class': 'ClassName', 'module_path': 'pkg.module', 'kwargs': {...}}.","Or pass a fully qualified string 'pkg.module.ClassName'.","Or pass the class object itself (e.g. MyHandlerClass) when it is already imported; make sure JSON configs are json.load()-ed before use."],"exampleFix":"// before\ninst = init_instance_by_config(['qlib.contrib.data.handler.Alpha158'])  # NotImplementedError\n\n// after\ninst = init_instance_by_config({'class': 'Alpha158', 'module_path': 'qlib.contrib.data.handler'})","handlingStrategy":"type-guard","validationCode":"from collections.abc import Mapping\nok = isinstance(conf, (str, type)) or (isinstance(conf, Mapping) and 'class' in conf)\nassert ok, f'bad instance config: {conf!r}'","typeGuard":"def is_valid_inst_conf(conf) -> bool:\n    return isinstance(conf, str) or isinstance(conf, type) or (isinstance(conf, Mapping) and 'class' in conf)","tryCatchPattern":"try:\n    inst = init_instance_by_config(conf)\nexcept NotImplementedError:\n    raise ValueError(f'config must be str/dict/class, got {type(conf).__name__}') from None","preventionTips":["Always json.load/yaml.safe_load config files before passing them in; unparsed JSON strings land in the str branch and fail differently.","A valid dict config must contain a 'class' key; unwrap single-element lists at the boundary."],"tags":["qlib","config","init-instance","notimplementederror","type-validation"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}