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

Class _SubclassOfValidator

src/attr/validators.py:597–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

595
596@attrs(repr=False, slots=True, unsafe_hash=True)
597class _SubclassOfValidator:
598 type = attrib()
599
600 def __call__(self, inst, attr, value):
601 """
602 We use a callable class to be able to change the ``__repr__``.
603 """
604 if not issubclass(value, self.type):
605 msg = f"'{attr.name}' must be a subclass of {self.type!r} (got {value!r})."
606 raise TypeError(
607 msg,
608 attr,
609 self.type,
610 value,
611 )
612
613 def __repr__(self):
614 return f"<subclass_of validator for type {self.type!r}>"
615
616
617def _subclass_of(type):

Callers 1

_subclass_ofFunction · 0.85

Calls 1

attribFunction · 0.85

Tested by

no test coverage detected