MCPcopy
hub / github.com/python-attrs/attrs / _NumberValidator

Class _NumberValidator

src/attr/validators.py:461–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

459
460@attrs(repr=False, frozen=True, slots=True)
461class _NumberValidator:
462 bound = attrib()
463 compare_op = attrib()
464 compare_func = attrib()
465
466 def __call__(self, inst, attr, value):
467 """
468 We use a callable class to be able to change the ``__repr__``.
469 """
470 if not self.compare_func(value, self.bound):
471 msg = f"'{attr.name}' must be {self.compare_op} {self.bound}: {value}"
472 raise ValueError(msg)
473
474 def __repr__(self):
475 return f"<Validator for x {self.compare_op} {self.bound}>"
476
477
478def lt(val):

Callers 4

ltFunction · 0.85
leFunction · 0.85
geFunction · 0.85
gtFunction · 0.85

Calls 1

attribFunction · 0.85

Tested by

no test coverage detected