A validator that raises a `TypeError` if the initializer is called with a wrong type for this particular attribute (checks are performed using `isinstance` therefore it's also valid to pass a tuple of types). Args: type (type | tuple[type]): The type to check for. Rais
(type)
| 111 | |
| 112 | |
| 113 | def instance_of(type): |
| 114 | class="st">""" |
| 115 | A validator that raises a `TypeError` if the initializer is called with a |
| 116 | wrong type for this particular attribute (checks are performed using |
| 117 | `isinstance` therefore it&class="cm">#x27;s also valid to pass a tuple of types). |
| 118 | |
| 119 | Args: |
| 120 | type (type | tuple[type]): The type to check for. |
| 121 | |
| 122 | Raises: |
| 123 | TypeError: |
| 124 | With a human readable error message, the attribute (of type |
| 125 | `attrs.Attribute`), the expected type, and the value it got. |
| 126 | class="st">""" |
| 127 | return _InstanceOfValidator(type) |
| 128 | |
| 129 | |
| 130 | @attrs(repr=False, frozen=True, slots=True) |