Use typing.Self throughout library

This commit is contained in:
Josh
2022-03-01 22:53:24 +10:00
committed by GitHub
parent a90e1824f4
commit 147948af9b
28 changed files with 212 additions and 191 deletions

View File

@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE.
from __future__ import annotations
import os
from typing import TYPE_CHECKING, Optional, Tuple, Type, TypeVar
from typing import TYPE_CHECKING, Optional, Tuple, TypeVar
from ..components import TextInput as TextInputComponent
from ..enums import ComponentType, TextStyle
@ -33,6 +33,8 @@ from ..utils import MISSING
from .item import Item
if TYPE_CHECKING:
from typing_extensions import Self
from ..types.components import TextInput as TextInputPayload
from ..types.interactions import ModalSubmitTextInputInteractionData as ModalSubmitTextInputInteractionDataPayload
from .view import View
@ -45,7 +47,6 @@ __all__ = (
# fmt: on
V = TypeVar('V', bound='View', covariant=True)
TI = TypeVar('TI', bound='TextInput')
class TextInput(Item[V]):
@ -210,7 +211,7 @@ class TextInput(Item[V]):
self._value = data.get('value', None)
@classmethod
def from_component(cls: Type[TI], component: TextInputComponent) -> TI:
def from_component(cls, component: TextInputComponent) -> Self:
return cls(
label=component.label,
style=component.style,