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

Class _OptionalValidator

src/attr/validators.py:201–211  ·  src/attr/validators.py::_OptionalValidator

Source from the content-addressed store, hash-verified

199
200@attrs(repr=False, slots=True, unsafe_hash=True)
201class _OptionalValidator:
202 validator = attrib()
203
204 def __call__(self, inst, attr, value):
205 if value is None:
206 return
207
208 self.validator(inst, attr, value)
209
210 def __repr__(self):
211 return fclass="st">"<optional validator for {self.validator!r} or None>"
212
213
214def optional(validator):

Callers 1

optionalFunction · 0.85

Calls 1

attribFunction · 0.85

Tested by

no test coverage detected