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

Class DeferredConfigString

traitlets/config/loader.py:390–420  ·  view source on GitHub ↗

Config value for loading config from a string Interpretation is deferred until it is loaded into the trait. Subclass of str for backward compatibility. This class is only used for values that are not listed in the configurable classes. When config is loaded, `trait.from_strin

Source from the content-addressed store, hash-verified

388
389
390class DeferredConfigString(str, DeferredConfig):
391 """Config value for loading config from a string
392
393 Interpretation is deferred until it is loaded into the trait.
394
395 Subclass of str for backward compatibility.
396
397 This class is only used for values that are not listed
398 in the configurable classes.
399
400 When config is loaded, `trait.from_string` will be used.
401
402 If an error is raised in `.from_string`,
403 the original string is returned.
404
405 .. versionadded:: 5.0
406 """
407
408 def get_value(self, trait: TraitType[t.Any, t.Any]) -> t.Any:
409 """Get the value stored in this string"""
410 s = str(self)
411 try:
412 return trait.from_string(s)
413 except Exception:
414 # exception casting from string,
415 # let the original string lie.
416 # this will raise a more informative error when config is loaded.
417 return s
418
419 def __repr__(self) -> str:
420 return f"{self.__class__.__name__}({self._super_repr()})"
421
422
423class DeferredConfigList(t.List[t.Any], DeferredConfig):

Callers 3

load_config_environMethod · 0.90
_exec_config_strMethod · 0.85
_convert_to_configMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…