Set config by ``id``. Args: config: config to set at location ``id``. id: id to specify the expected position. See also :py:meth:`__setitem__`. recursive: if the nested id doesn't exist, whether to recursively create the nested items in the confi
(self, config: Any, id: str = "", recursive: bool = True)
| 410 | return default |
| 411 | |
| 412 | def set(self, config: Any, id: str = "", recursive: bool = True) -> None: |
| 413 | """ |
| 414 | Set config by ``id``. |
| 415 | |
| 416 | Args: |
| 417 | config: config to set at location ``id``. |
| 418 | id: id to specify the expected position. See also :py:meth:`__setitem__`. |
| 419 | recursive: if the nested id doesn't exist, whether to recursively create the nested items in the config. |
| 420 | default to `True`. for the nested id, only support `dict` for the missing section. |
| 421 | |
| 422 | """ |
| 423 | keys = ReferenceResolver.split_id(id) |
| 424 | conf_ = self.get() |
| 425 | if recursive: |
| 426 | if conf_ is None: |
| 427 | self.config = conf_ = {} # type: ignore |
| 428 | for k in keys[:-1]: |
| 429 | if isinstance(conf_, dict) and k not in conf_: |
| 430 | conf_[k] = {} |
| 431 | conf_ = conf_[k if isinstance(conf_, dict) else int(k)] |
| 432 | self[ReferenceResolver.normalize_id(id)] = self.ref_resolver.normalize_meta_id(config) |
| 433 | |
| 434 | def update(self, pairs: dict[str, Any]) -> None: |
| 435 | """ |