|
25 | 25 | "Item", |
26 | 26 | ) |
27 | 27 |
|
28 | | -I = TypeVar("I", bound="Item[Any]") # noqa: E741 |
29 | | -V_co = TypeVar("V_co", bound="Optional[View]", covariant=True) |
30 | 28 |
|
31 | 29 | if TYPE_CHECKING: |
32 | | - from typing_extensions import Self |
| 30 | + from typing_extensions import ( |
| 31 | + Self, |
| 32 | + TypeVar, # noqa: TC004 |
| 33 | + ) |
33 | 34 |
|
34 | 35 | from ..client import Client |
35 | 36 | from ..components import ActionRowChildComponent, Component |
|
38 | 39 | from ..types.components import ActionRowChildComponent as ActionRowChildComponentPayload |
39 | 40 | from .view import View |
40 | 41 |
|
| 42 | + V_co = TypeVar("V_co", bound="Optional[View]", covariant=True, default=None) |
| 43 | + I = TypeVar("I", bound="Item[Any]", default="Item[None]") # noqa: E741 |
41 | 44 | ItemCallbackType = Callable[[V_co, I, MessageInteraction], Coroutine[Any, Any, Any]] |
42 | 45 |
|
| 46 | + SelfViewT = TypeVar("SelfViewT", bound="Optional[View]", default=None) |
| 47 | +else: |
| 48 | + I = TypeVar("I", bound="Item[Any]") # noqa: E741 |
| 49 | + V_co = TypeVar("V_co", bound="Optional[View]", covariant=True) |
| 50 | + |
| 51 | + SelfViewT = TypeVar("SelfViewT", bound="Optional[View]") |
| 52 | + |
| 53 | + |
43 | 54 | ClientT = TypeVar("ClientT", bound="Client") |
44 | 55 | UIComponentT = TypeVar("UIComponentT", bound="UIComponent") |
45 | 56 |
|
@@ -220,9 +231,6 @@ async def callback(self, interaction: MessageInteraction[ClientT], /) -> None: |
220 | 231 | pass |
221 | 232 |
|
222 | 233 |
|
223 | | -SelfViewT = TypeVar("SelfViewT", bound="Optional[View]") |
224 | | - |
225 | | - |
226 | 234 | # While the decorators don't actually return a descriptor that matches this protocol, |
227 | 235 | # this protocol ensures that type checkers don't complain about statements like `self.button.disabled = True`, |
228 | 236 | # which work as `View.__init__` replaces the handler with the item. |
|
0 commit comments