MCPcopy Create free account
hub / github.com/ipython/traitlets / _exec_config_str

Method _exec_config_str

traitlets/config/loader.py:665–692  ·  view source on GitHub ↗

execute self.config. = * expands ~ with expanduser * interprets value with trait if available

(
        self, lhs: t.Any, rhs: t.Any, trait: TraitType[t.Any, t.Any] | None = None
    )

Source from the content-addressed store, hash-verified

663 """
664
665 def _exec_config_str(
666 self, lhs: t.Any, rhs: t.Any, trait: TraitType[t.Any, t.Any] | None = None
667 ) -> None:
668 """execute self.config.<lhs> = <rhs>
669
670 * expands ~ with expanduser
671 * interprets value with trait if available
672 """
673 value = rhs
674 if isinstance(value, DeferredConfig):
675 if trait:
676 # trait available, reify config immediately
677 value = value.get_value(trait)
678 elif isinstance(rhs, DeferredConfigList) and len(rhs) == 1:
679 # single item, make it a deferred str
680 value = DeferredConfigString(os.path.expanduser(rhs[0]))
681 else:
682 if trait:
683 value = trait.from_string(value)
684 else:
685 value = DeferredConfigString(value)
686
687 *path, key = lhs.split(".")
688 section = self.config
689 for part in path:
690 section = section[part]
691 section[key] = value
692 return
693
694 def _load_flag(self, cfg: t.Any) -> None:
695 """update self.config from a flag, which can be a dict or Config"""

Callers 1

_convert_to_configMethod · 0.80

Calls 3

get_valueMethod · 0.95
from_stringMethod · 0.45

Tested by

no test coverage detected