| 1088 | return f'<single dispatch method {name}>' |
| 1089 | |
| 1090 | def __call__(self, /, *args, **kwargs): |
| 1091 | if not args: |
| 1092 | funcname = getattr(self._unbound.func, '__name__', |
| 1093 | 'singledispatchmethod method') |
| 1094 | raise TypeError(f'{funcname} requires at least ' |
| 1095 | '1 positional argument') |
| 1096 | method = self._dispatch(args[self._dispatch_arg_index].__class__) |
| 1097 | |
| 1098 | if hasattr(method, "__get__"): |
| 1099 | # If the method is a descriptor, it might be necessary |
| 1100 | # to drop the first argument before calling |
| 1101 | # as it can be no longer expected after descriptor access. |
| 1102 | skip_bound_arg = False |
| 1103 | if isinstance(method, staticmethod): |
| 1104 | skip_bound_arg = self._dispatch_arg_index == 1 |
| 1105 | |
| 1106 | method = method.__get__(self._obj, self._cls) |
| 1107 | if isinstance(method, MethodType): |
| 1108 | skip_bound_arg = self._dispatch_arg_index == 1 |
| 1109 | |
| 1110 | if skip_bound_arg: |
| 1111 | return method(*args[1:], **kwargs) |
| 1112 | return method(*args, **kwargs) |
| 1113 | |
| 1114 | def __getattr__(self, name): |
| 1115 | # Resolve these attributes lazily to speed up creation of |