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

@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE.
from __future__ import annotations
from typing import Any, Dict, List, Optional, Union, Type, TypeVar, TYPE_CHECKING
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union
import discord.abc
from .asset import Asset
@ -34,6 +34,8 @@ from .flags import PublicUserFlags
from .utils import snowflake_time, _bytes_to_base64_data, MISSING
if TYPE_CHECKING:
from typing_extensions import Self
from datetime import datetime
from .channel import DMChannel
@ -52,8 +54,6 @@ __all__ = (
'ClientUser',
)
BU = TypeVar('BU', bound='BaseUser')
class _UserTag:
__slots__ = ()
@ -120,7 +120,7 @@ class BaseUser(_UserTag):
self.system = data.get('system', False)
@classmethod
def _copy(cls: Type[BU], user: BU) -> BU:
def _copy(cls, user: Self) -> Self:
self = cls.__new__(cls) # bypass __init__
self.name = user.name