mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-04 08:56:19 +00:00
Fix some type-check errors
This commit is contained in:
@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, List, Optional, Type, TypeVar, TYPE_CHECKING
|
||||
from typing import Any, Dict, List, Optional, Union, Type, TypeVar, TYPE_CHECKING
|
||||
|
||||
import discord.abc
|
||||
from .asset import Asset
|
||||
@ -41,7 +41,10 @@ if TYPE_CHECKING:
|
||||
from .message import Message
|
||||
from .state import ConnectionState
|
||||
from .types.channel import DMChannel as DMChannelPayload
|
||||
from .types.user import User as UserPayload
|
||||
from .types.user import (
|
||||
PartialUser as PartialUserPayload,
|
||||
User as UserPayload,
|
||||
)
|
||||
|
||||
|
||||
__all__ = (
|
||||
@ -83,7 +86,7 @@ class BaseUser(_UserTag):
|
||||
_accent_colour: Optional[int]
|
||||
_public_flags: int
|
||||
|
||||
def __init__(self, *, state: ConnectionState, data: UserPayload) -> None:
|
||||
def __init__(self, *, state: ConnectionState, data: Union[UserPayload, PartialUserPayload]) -> None:
|
||||
self._state = state
|
||||
self._update(data)
|
||||
|
||||
@ -105,7 +108,7 @@ class BaseUser(_UserTag):
|
||||
def __hash__(self) -> int:
|
||||
return self.id >> 22
|
||||
|
||||
def _update(self, data: UserPayload) -> None:
|
||||
def _update(self, data: Union[UserPayload, PartialUserPayload]) -> None:
|
||||
self.name = data['username']
|
||||
self.id = int(data['id'])
|
||||
self.discriminator = data['discriminator']
|
||||
|
Reference in New Issue
Block a user