mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-07 10:22:59 +00:00
Use typing.Self throughout library
This commit is contained in:
@ -24,12 +24,14 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, ClassVar, Dict, List, Optional, TYPE_CHECKING, Tuple, Type, TypeVar, Union
|
||||
from typing import Any, ClassVar, Dict, List, Optional, TYPE_CHECKING, Tuple, Union
|
||||
from .enums import try_enum, ComponentType, ButtonStyle, TextStyle
|
||||
from .utils import get_slots, MISSING
|
||||
from .partial_emoji import PartialEmoji, _EmojiTag
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing_extensions import Self
|
||||
|
||||
from .types.components import (
|
||||
Component as ComponentPayload,
|
||||
ButtonComponent as ButtonComponentPayload,
|
||||
@ -50,8 +52,6 @@ __all__ = (
|
||||
'TextInput',
|
||||
)
|
||||
|
||||
C = TypeVar('C', bound='Component')
|
||||
|
||||
|
||||
class Component:
|
||||
"""Represents a Discord Bot UI Kit Component.
|
||||
@ -82,8 +82,8 @@ class Component:
|
||||
return f'<{self.__class__.__name__} {attrs}>'
|
||||
|
||||
@classmethod
|
||||
def _raw_construct(cls: Type[C], **kwargs) -> C:
|
||||
self: C = cls.__new__(cls)
|
||||
def _raw_construct(cls, **kwargs) -> Self:
|
||||
self = cls.__new__(cls)
|
||||
for slot in get_slots(cls):
|
||||
try:
|
||||
value = kwargs[slot]
|
||||
|
Reference in New Issue
Block a user