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

Method validate

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

Source from the content-addressed store, hash-verified

2641 )
2642
2643 def validate(self, obj: t.Any, value: t.Any) -> G:
2644 if not isinstance(value, int) and isinstance(value, numbers.Number):
2645 # allow casting integer-valued numbers to int
2646 # allows for more concise assignment like `4e9` which is a float
2647 try:
2648 int_value = int(value)
2649 if int_value == value:
2650 value = int_value
2651 except Exception:
2652 pass
2653 if not isinstance(value, int):
2654 self.error(obj, value)
2655 return _validate_bounds(self, obj, value) # type:ignore[no-any-return]
2656
2657 def from_string(self, s: str) -> G:
2658 if self.allow_none and s == "None":

Callers 4

_validateMethod · 0.45
from_stringMethod · 0.45
validateMethod · 0.45
validateMethod · 0.45

Calls 2

_validate_boundsFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected