MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / _InValidator

Class _InValidator

src/licensedcode/_vendor/attr/validators.py:296–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294
295@attrs(repr=False, slots=True, hash=True)
296class _InValidator(object):
297 options = attrib()
298
299 def __call__(self, inst, attr, value):
300 try:
301 in_options = value in self.options
302 except TypeError: # e.g. `1 in "abc"`
303 in_options = False
304
305 if not in_options:
306 raise ValueError(
307 "'{name}' must be in {options!r} (got {value!r})".format(
308 name=attr.name, options=self.options, value=value
309 )
310 )
311
312 def __repr__(self):
313 return "<in_ validator with options {options!r}>".format(
314 options=self.options
315 )
316
317
318def in_(options):

Callers 1

in_Function · 0.85

Calls 1

attribFunction · 0.85

Tested by

no test coverage detected