| 595 | |
| 596 | @attrs(repr=False, slots=True, unsafe_hash=True) |
| 597 | class _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 | |
| 617 | def _subclass_of(type): |
no test coverage detected