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

Method from_string

traitlets/traitlets.py:3526–3534  ·  view source on GitHub ↗

Load value from a single string

(self, s: str)

Source from the content-addressed store, hash-verified

3524 # to opt out of instance_init
3525
3526 def from_string(self, s: str) -> T | None:
3527 """Load value from a single string"""
3528 if not isinstance(s, str):
3529 raise TraitError(f"Expected string, got {s!r}")
3530 try:
3531 test = literal_eval(s)
3532 except Exception:
3533 test = None
3534 return self.validate(None, test)
3535
3536 def from_string_list(self, s_list: list[str]) -> T | None:
3537 """Return the value from a list of config strings

Callers

nothing calls this directly

Calls 2

validateMethod · 0.95
TraitErrorClass · 0.85

Tested by

no test coverage detected