mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-05 01:16:21 +00:00
Use typing.Self throughout library
This commit is contained in:
@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
from typing import Any, Callable, Deque, Dict, Optional, Type, TypeVar, TYPE_CHECKING
|
||||
from typing import Any, Callable, Deque, Dict, Optional, TYPE_CHECKING
|
||||
from discord.enums import Enum
|
||||
import time
|
||||
import asyncio
|
||||
@ -35,6 +35,8 @@ from ...abc import PrivateChannel
|
||||
from .errors import MaxConcurrencyReached
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing_extensions import Self
|
||||
|
||||
from ...message import Message
|
||||
|
||||
__all__ = (
|
||||
@ -45,9 +47,6 @@ __all__ = (
|
||||
'MaxConcurrency',
|
||||
)
|
||||
|
||||
C = TypeVar('C', bound='CooldownMapping')
|
||||
MC = TypeVar('MC', bound='MaxConcurrency')
|
||||
|
||||
|
||||
class BucketType(Enum):
|
||||
default = 0
|
||||
@ -221,7 +220,7 @@ class CooldownMapping:
|
||||
return self._type
|
||||
|
||||
@classmethod
|
||||
def from_cooldown(cls: Type[C], rate, per, type) -> C:
|
||||
def from_cooldown(cls, rate, per, type) -> Self:
|
||||
return cls(Cooldown(rate, per), type)
|
||||
|
||||
def _bucket_key(self, msg: Message) -> Any:
|
||||
@ -356,7 +355,7 @@ class MaxConcurrency:
|
||||
if not isinstance(per, BucketType):
|
||||
raise TypeError(f'max_concurrency \'per\' must be of type BucketType not {type(per)!r}')
|
||||
|
||||
def copy(self: MC) -> MC:
|
||||
def copy(self) -> Self:
|
||||
return self.__class__(self.number, per=self.per, wait=self.wait)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
|
Reference in New Issue
Block a user