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

Method _value_validate

tests/test_traitlets.py:1968–1974  ·  view source on GitHub ↗
(self, proposal)

Source from the content-addressed store, hash-verified

1966
1967 @validate("value")
1968 def _value_validate(self, proposal):
1969 value = proposal["value"]
1970 if self.parity == "even" and value % 2:
1971 raise TraitError("Expected an even number")
1972 if self.parity == "odd" and (value % 2 == 0):
1973 raise TraitError("Expected an odd number")
1974 return value
1975
1976 u = Parity()
1977 u.parity = "odd"

Callers

nothing calls this directly

Calls 1

TraitErrorClass · 0.90

Tested by

no test coverage detected