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

Method validate

traitlets/traitlets.py:2953–2962  ·  view source on GitHub ↗
(self, obj: t.Any, value: t.Any)

Source from the content-addressed store, hash-verified

2951 ...
2952
2953 def validate(self, obj: t.Any, value: t.Any) -> G:
2954 if isinstance(value, str):
2955 return value # type:ignore[return-value]
2956 if isinstance(value, bytes):
2957 try:
2958 return value.decode("ascii", "strict") # type:ignore[return-value]
2959 except UnicodeDecodeError as e:
2960 msg = "Could not decode {!r} for unicode trait '{}' of {} instance."
2961 raise TraitError(msg.format(value, self.name, class_of(obj))) from e
2962 self.error(obj, value)
2963
2964 def from_string(self, s: str) -> G:
2965 if self.allow_none and s == "None":

Callers

nothing calls this directly

Calls 4

TraitErrorClass · 0.85
class_ofFunction · 0.85
formatMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected