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

@ -23,7 +23,7 @@ DEALINGS IN THE SOFTWARE.
"""
from __future__ import annotations
from typing import Type, TypeVar, Union, List, TYPE_CHECKING, Any, Union
from typing import Union, List, TYPE_CHECKING, Any, Union
# fmt: off
__all__ = (
@ -32,6 +32,8 @@ __all__ = (
# fmt: on
if TYPE_CHECKING:
from typing_extensions import Self
from .types.message import AllowedMentions as AllowedMentionsPayload
from .abc import Snowflake
@ -49,8 +51,6 @@ class _FakeBool:
default: Any = _FakeBool()
A = TypeVar('A', bound='AllowedMentions')
class AllowedMentions:
"""A class that represents what mentions are allowed in a message.
@ -98,7 +98,7 @@ class AllowedMentions:
self.replied_user = replied_user
@classmethod
def all(cls: Type[A]) -> A:
def all(cls) -> Self:
"""A factory method that returns a :class:`AllowedMentions` with all fields explicitly set to ``True``
.. versionadded:: 1.5
@ -106,7 +106,7 @@ class AllowedMentions:
return cls(everyone=True, users=True, roles=True, replied_user=True)
@classmethod
def none(cls: Type[A]) -> A:
def none(cls) -> Self:
"""A factory method that returns a :class:`AllowedMentions` with all fields set to ``False``
.. versionadded:: 1.5