| 293 | |
| 294 | @attrs(repr=False, slots=False, unsafe_hash=True) |
| 295 | class _IsCallableValidator: |
| 296 | def __call__(self, inst, attr, value): |
| 297 | """ |
| 298 | We use a callable class to be able to change the ``__repr__``. |
| 299 | """ |
| 300 | if not callable(value): |
| 301 | message = ( |
| 302 | "'{name}' must be callable " |
| 303 | "(got {value!r} that is a {actual!r})." |
| 304 | ) |
| 305 | raise NotCallableError( |
| 306 | msg=message.format( |
| 307 | name=attr.name, value=value, actual=value.__class__ |
| 308 | ), |
| 309 | value=value, |
| 310 | ) |
| 311 | |
| 312 | def __repr__(self): |
| 313 | return "<is_callable validator>" |
| 314 | |
| 315 | |
| 316 | def is_callable(): |