|
84 | 84 |
|
85 | 85 | _AutocompleteValueT = typing.TypeVar("_AutocompleteValueT", int, str, float)
|
86 | 86 | _BaseSlashCommandT = typing.TypeVar("_BaseSlashCommandT", bound="BaseSlashCommand")
|
87 |
| - _CommandCallbackSigT = typing.TypeVar("_CommandCallbackSigT", bound="CommandCallbackSig") |
88 |
| - _ErrorHookSigT = typing.TypeVar("_ErrorHookSigT", bound="ErrorHookSig") |
89 |
| - _HookSigT = typing.TypeVar("_HookSigT", bound="HookSig") |
| 87 | + |
| 88 | + _AnyErrorHookSigT = typing.TypeVar("_AnyErrorHookSigT", bound="ErrorHookSig[typing.Any]") |
| 89 | + _MenuErrorHookSigT = typing.TypeVar("_MenuErrorHookSigT", bound="ErrorHookSig[MenuContext]") |
| 90 | + _MessageErrorHookSigT = typing.TypeVar("_MessageErrorHookSigT", bound="ErrorHookSig[MessageContext]") |
| 91 | + _SlashErrorHookSigT = typing.TypeVar("_SlashErrorHookSigT", bound="ErrorHookSig[SlashContext]") |
| 92 | + |
| 93 | + _AnyHookSigT = typing.TypeVar("_AnyHookSigT", bound="HookSig[typing.Any]") |
| 94 | + _MenuHookSigT = typing.TypeVar("_MenuHookSigT", bound="HookSig[MenuContext]") |
| 95 | + _MessageHookSigT = typing.TypeVar("_MessageHookSigT", bound="HookSig[MessageContext]") |
| 96 | + _SlashHookSigT = typing.TypeVar("_SlashHookSigT", bound="HookSig[SlashContext]") |
| 97 | + |
90 | 98 | _ListenerCallbackSigT = typing.TypeVar("_ListenerCallbackSigT", bound="ListenerCallbackSig")
|
91 | 99 | _MenuCommandT = typing.TypeVar("_MenuCommandT", bound="MenuCommand[typing.Any, typing.Any]")
|
92 | 100 | _MessageCommandT = typing.TypeVar("_MessageCommandT", bound="MessageCommand[typing.Any]")
|
|
133 | 141 | SlashCheckSig = _CheckSig["SlashContext", ...]
|
134 | 142 |
|
135 | 143 |
|
136 |
| -_CommandCallbackSig = collections.Callable[typing_extensions.Concatenate[_ContextT_contra, _P], collections.Coroutine[typing.Any, typing.Any, None]] |
| 144 | +_CommandCallbackSig = collections.Callable[ |
| 145 | + typing_extensions.Concatenate[_ContextT_contra, _P], collections.Coroutine[typing.Any, typing.Any, None] |
| 146 | +] |
137 | 147 |
|
138 |
| -_MenuValueT = typing.TypeVar("_MenuValueT", hikari.User, hikari.InteractionMember) |
| 148 | +_MenuValueT = typing.TypeVar("_MenuValueT", hikari.Message, hikari.InteractionMember) |
139 | 149 | _ManuCallbackSig = collections.Callable[
|
140 | 150 | typing_extensions.Concatenate[_ContextT_contra, _MenuValueT, _P],
|
141 |
| - collections.Coroutine[typing.Any, typing.Any, None] |
| 151 | + collections.Coroutine[typing.Any, typing.Any, None], |
142 | 152 | ]
|
143 | 153 | MenuCallbackSig = _ManuCallbackSig["MenuContext", _MenuValueT, ...]
|
144 | 154 | """Type hint of a context menu command callback.
|
@@ -2155,8 +2165,23 @@ def add_on_error(self, callback: ErrorHookSig[_ContextT_contra], /) -> Self:
|
2155 | 2165 | The hook object to enable method chaining.
|
2156 | 2166 | """
|
2157 | 2167 |
|
| 2168 | + @typing.overload |
| 2169 | + @abc.abstractmethod |
| 2170 | + def with_on_error(self: MenuHooks, callback: _MenuErrorHookSigT, /) -> _MenuErrorHookSigT: |
| 2171 | + ... |
| 2172 | + |
| 2173 | + @typing.overload |
| 2174 | + @abc.abstractmethod |
| 2175 | + def with_on_error(self: MessageHooks, callback: _MessageErrorHookSigT, /) -> _MessageErrorHookSigT: |
| 2176 | + ... |
| 2177 | + |
| 2178 | + @typing.overload |
| 2179 | + @abc.abstractmethod |
| 2180 | + def with_on_error(self: SlashHooks, callback: _SlashErrorHookSigT, /) -> _SlashErrorHookSigT: |
| 2181 | + ... |
| 2182 | + |
2158 | 2183 | @abc.abstractmethod
|
2159 |
| - def with_on_error(self, callback: _ErrorHookSigT, /) -> _ErrorHookSigT: |
| 2184 | + def with_on_error(self, callback: _AnyErrorHookSigT, /) -> _AnyErrorHookSigT: |
2160 | 2185 | """Add an error callback to this hook object through a decorator call.
|
2161 | 2186 |
|
2162 | 2187 | !!! note
|
@@ -2219,8 +2244,23 @@ def add_on_parser_error(self, callback: HookSig[_ContextT_contra], /) -> Self:
|
2219 | 2244 | The hook object to enable method chaining.
|
2220 | 2245 | """
|
2221 | 2246 |
|
| 2247 | + @typing.overload |
| 2248 | + @abc.abstractmethod |
| 2249 | + def with_on_parser_error(self: MenuHooks, callback: _MenuHookSigT, /) -> _MenuHookSigT: |
| 2250 | + ... |
| 2251 | + |
| 2252 | + @typing.overload |
| 2253 | + @abc.abstractmethod |
| 2254 | + def with_on_parser_error(self: MessageHooks, callback: _MessageHookSigT, /) -> _MessageHookSigT: |
| 2255 | + ... |
| 2256 | + |
| 2257 | + @typing.overload |
| 2258 | + @abc.abstractmethod |
| 2259 | + def with_on_parser_error(self: SlashHooks, callback: _SlashHookSigT, /) -> _SlashHookSigT: |
| 2260 | + ... |
| 2261 | + |
2222 | 2262 | @abc.abstractmethod
|
2223 |
| - def with_on_parser_error(self, callback: _HookSigT, /) -> _HookSigT: |
| 2263 | + def with_on_parser_error(self, callback: _AnyHookSigT, /) -> _AnyHookSigT: |
2224 | 2264 | """Add a parser error callback to this hook object through a decorator call.
|
2225 | 2265 |
|
2226 | 2266 | Examples
|
@@ -2267,8 +2307,23 @@ def add_post_execution(self, callback: HookSig[_ContextT_contra], /) -> Self:
|
2267 | 2307 | The hook object to enable method chaining.
|
2268 | 2308 | """
|
2269 | 2309 |
|
| 2310 | + @typing.overload |
| 2311 | + @abc.abstractmethod |
| 2312 | + def with_post_execution(self: MenuHooks, callback: _MenuHookSigT, /) -> _MenuHookSigT: |
| 2313 | + ... |
| 2314 | + |
| 2315 | + @typing.overload |
| 2316 | + @abc.abstractmethod |
| 2317 | + def with_post_execution(self: MessageHooks, callback: _MessageHookSigT, /) -> _MessageHookSigT: |
| 2318 | + ... |
| 2319 | + |
| 2320 | + @typing.overload |
| 2321 | + @abc.abstractmethod |
| 2322 | + def with_post_execution(self: SlashHooks, callback: _SlashHookSigT, /) -> _SlashHookSigT: |
| 2323 | + ... |
| 2324 | + |
2270 | 2325 | @abc.abstractmethod
|
2271 |
| - def with_post_execution(self, callback: _HookSigT, /) -> _HookSigT: |
| 2326 | + def with_post_execution(self, callback: _AnyHookSigT, /) -> _AnyHookSigT: |
2272 | 2327 | """Add a post-execution callback to this hook object through a decorator call.
|
2273 | 2328 |
|
2274 | 2329 | Examples
|
@@ -2315,8 +2370,23 @@ def add_pre_execution(self, callback: HookSig[_ContextT_contra], /) -> Self:
|
2315 | 2370 | The hook object to enable method chaining.
|
2316 | 2371 | """
|
2317 | 2372 |
|
| 2373 | + @typing.overload |
| 2374 | + @abc.abstractmethod |
| 2375 | + def with_pre_execution(self: MenuHooks, callback: _MenuHookSigT, /) -> _MenuHookSigT: |
| 2376 | + ... |
| 2377 | + |
| 2378 | + @typing.overload |
| 2379 | + @abc.abstractmethod |
| 2380 | + def with_pre_execution(self: MessageHooks, callback: _MessageHookSigT, /) -> _MessageHookSigT: |
| 2381 | + ... |
| 2382 | + |
| 2383 | + @typing.overload |
| 2384 | + @abc.abstractmethod |
| 2385 | + def with_pre_execution(self: SlashHooks, callback: _SlashHookSigT, /) -> _SlashHookSigT: |
| 2386 | + ... |
| 2387 | + |
2318 | 2388 | @abc.abstractmethod
|
2319 |
| - def with_pre_execution(self, callback: _HookSigT, /) -> _HookSigT: |
| 2389 | + def with_pre_execution(self, callback: _AnyHookSigT, /) -> _AnyHookSigT: |
2320 | 2390 | """Add a pre-execution callback to this hook object through a decorator call.
|
2321 | 2391 |
|
2322 | 2392 | Examples
|
@@ -2363,8 +2433,23 @@ def add_on_success(self, callback: HookSig[_ContextT_contra], /) -> Self:
|
2363 | 2433 | The hook object to enable method chaining.
|
2364 | 2434 | """
|
2365 | 2435 |
|
| 2436 | + @typing.overload |
| 2437 | + @abc.abstractmethod |
| 2438 | + def with_on_success(self: MenuHooks, callback: _MenuHookSigT, /) -> _MenuHookSigT: |
| 2439 | + ... |
| 2440 | + |
| 2441 | + @typing.overload |
| 2442 | + @abc.abstractmethod |
| 2443 | + def with_on_success(self: MessageHooks, callback: _MessageHookSigT, /) -> _MessageHookSigT: |
| 2444 | + ... |
| 2445 | + |
| 2446 | + @typing.overload |
| 2447 | + @abc.abstractmethod |
| 2448 | + def with_on_success(self: SlashHooks, callback: _SlashHookSigT, /) -> _SlashHookSigT: |
| 2449 | + ... |
| 2450 | + |
2366 | 2451 | @abc.abstractmethod
|
2367 |
| - def with_on_success(self, callback: _HookSigT, /) -> _HookSigT: |
| 2452 | + def with_on_success(self, callback: _AnyHookSigT, /) -> _AnyHookSigT: |
2368 | 2453 | """Add a success callback to this hook object through a decorator call.
|
2369 | 2454 |
|
2370 | 2455 | Examples
|
|
0 commit comments