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

Method from_string

traitlets/traitlets.py:594–608  ·  view source on GitHub ↗

Get a value from a config string such as an environment variable or CLI arguments. Traits can override this method to define their own parsing of config strings. .. seealso:: item_from_string .. versionadded:: 5.0

(self, s: str)

Source from the content-addressed store, hash-verified

592 self.metadata["help"] = help
593
594 def from_string(self, s: str) -> G | None:
595 """Get a value from a config string
596
597 such as an environment variable or CLI arguments.
598
599 Traits can override this method to define their own
600 parsing of config strings.
601
602 .. seealso:: item_from_string
603
604 .. versionadded:: 5.0
605 """
606 if self.allow_none and s == "None":
607 return None
608 return s # type:ignore[return-value]
609
610 def default(self, obj: t.Any = None) -> G | None:
611 """The default generator for this trait

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected