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

Class _InValidator

src/attr/validators.py:236–256  ·  src/attr/validators.py::_InValidator

Source from the content-addressed store, hash-verified

234
235@attrs(repr=False, slots=True, unsafe_hash=True)
236class _InValidator:
237 options = attrib()
238 _original_options = attrib(hash=False)
239
240 def __call__(self, inst, attr, value):
241 try:
242 in_options = value in self.options
243 except TypeError: class="cm"># e.g. `1 in class="st">"abc"`
244 in_options = False
245
246 if not in_options:
247 msg = fclass="st">"&class="cm">#x27;{attr.name}' must be in {self._original_options!r} (got {value!r})"
248 raise ValueError(
249 msg,
250 attr,
251 self._original_options,
252 value,
253 )
254
255 def __repr__(self):
256 return fclass="st">"<in_ validator with options {self._original_options!r}>"
257
258
259def in_(options):

Callers 1

in_Function · 0.85

Calls 1

attribFunction · 0.85

Tested by

no test coverage detected