Small helper that raises exceptions if you try to get/set any attribute on it.
| 30 | |
| 31 | |
| 32 | class NotSupported: |
| 33 | """ |
| 34 | Small helper that raises exceptions if you try to get/set any attribute on |
| 35 | it. |
| 36 | """ |
| 37 | |
| 38 | def __init__(self, name, error): |
| 39 | object.__setattr__(self, "name", name) |
| 40 | object.__setattr__(self, "error", error) |
| 41 | |
| 42 | def __repr__(self): |
| 43 | return f"<NotSupported {self.name} [{self.error}]>" |
| 44 | |
| 45 | def __getattr__(self, attr): |
| 46 | raise AttributeError(self.error) |
| 47 | |
| 48 | def __setattr__(self, attr, value): |
| 49 | raise AttributeError(self.error) |
| 50 | |
| 51 | def __call__(self, *args): |
| 52 | raise TypeError(self.error) |
| 53 | |
| 54 | |
| 55 | def is_awaitable(obj): |