mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-16 18:59:09 +00:00
Add utils.MISSING
This commit is contained in:
parent
a2df6e81b8
commit
c786a85a9b
@ -24,14 +24,13 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import sys
|
|
||||||
import copy
|
import copy
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import TYPE_CHECKING, Protocol, runtime_checkable
|
from typing import TYPE_CHECKING, Protocol, runtime_checkable
|
||||||
|
|
||||||
from .iterators import HistoryIterator
|
from .iterators import HistoryIterator
|
||||||
from .context_managers import Typing
|
from .context_managers import Typing
|
||||||
from .enums import ChannelType, VideoQualityMode
|
from .enums import ChannelType
|
||||||
from .errors import InvalidArgument, ClientException
|
from .errors import InvalidArgument, ClientException
|
||||||
from .mentions import AllowedMentions
|
from .mentions import AllowedMentions
|
||||||
from .permissions import PermissionOverwrite, Permissions
|
from .permissions import PermissionOverwrite, Permissions
|
||||||
@ -692,7 +691,7 @@ class GuildChannel(Protocol):
|
|||||||
else:
|
else:
|
||||||
raise InvalidArgument('target parameter must be either Member or Role')
|
raise InvalidArgument('target parameter must be either Member or Role')
|
||||||
|
|
||||||
if isinstance(overwrite, _Undefined):
|
if overwrite is _undefined:
|
||||||
if len(permissions) == 0:
|
if len(permissions) == 0:
|
||||||
raise InvalidArgument('No overwrite provided.')
|
raise InvalidArgument('No overwrite provided.')
|
||||||
try:
|
try:
|
||||||
|
@ -36,7 +36,7 @@ from discord.utils import resolve_annotation
|
|||||||
from .view import StringView
|
from .view import StringView
|
||||||
from .converter import run_converters
|
from .converter import run_converters
|
||||||
|
|
||||||
from discord.utils import maybe_coroutine
|
from discord.utils import maybe_coroutine, MISSING
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import (
|
from typing import (
|
||||||
Dict,
|
Dict,
|
||||||
@ -69,14 +69,6 @@ if TYPE_CHECKING:
|
|||||||
from .context import Context
|
from .context import Context
|
||||||
|
|
||||||
|
|
||||||
class _MissingSentinel:
|
|
||||||
def __repr__(self):
|
|
||||||
return 'MISSING'
|
|
||||||
|
|
||||||
|
|
||||||
MISSING: Any = _MissingSentinel()
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Flag:
|
class Flag:
|
||||||
"""Represents a flag parameter for :class:`FlagConverter`.
|
"""Represents a flag parameter for :class:`FlagConverter`.
|
||||||
|
@ -79,6 +79,17 @@ __all__ = (
|
|||||||
DISCORD_EPOCH = 1420070400000
|
DISCORD_EPOCH = 1420070400000
|
||||||
|
|
||||||
|
|
||||||
|
class _MissingSentinel:
|
||||||
|
def __eq__(self, other):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '...'
|
||||||
|
|
||||||
|
|
||||||
|
MISSING: Any = _MissingSentinel()
|
||||||
|
|
||||||
|
|
||||||
class _cached_property:
|
class _cached_property:
|
||||||
def __init__(self, function):
|
def __init__(self, function):
|
||||||
self.function = function
|
self.function = function
|
||||||
|
@ -28,7 +28,6 @@ import contextvars
|
|||||||
import logging
|
import logging
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import time
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from urllib.parse import quote as urlquote
|
from urllib.parse import quote as urlquote
|
||||||
@ -67,16 +66,7 @@ if TYPE_CHECKING:
|
|||||||
from ..abc import Snowflake
|
from ..abc import Snowflake
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
MISSING = utils.MISSING
|
||||||
class _Missing:
|
|
||||||
def __bool__(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return '...'
|
|
||||||
|
|
||||||
|
|
||||||
MISSING: Any = _Missing()
|
|
||||||
|
|
||||||
|
|
||||||
class AsyncDeferredLock:
|
class AsyncDeferredLock:
|
||||||
@ -731,6 +721,7 @@ class BaseWebhook(Hashable):
|
|||||||
return Asset._from_default_avatar(self._state, 0)
|
return Asset._from_default_avatar(self._state, 0)
|
||||||
return Asset._from_avatar(self._state, self.id, self._avatar)
|
return Asset._from_avatar(self._state, self.id, self._avatar)
|
||||||
|
|
||||||
|
|
||||||
class Webhook(BaseWebhook):
|
class Webhook(BaseWebhook):
|
||||||
"""Represents an asynchronous Discord webhook.
|
"""Represents an asynchronous Discord webhook.
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ from ..message import Message
|
|||||||
from ..http import Route
|
from ..http import Route
|
||||||
from ..object import Object
|
from ..object import Object
|
||||||
|
|
||||||
from .async_ import BaseWebhook, handle_message_parameters, _WebhookState, MISSING
|
from .async_ import BaseWebhook, handle_message_parameters, _WebhookState
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'SyncWebhook',
|
'SyncWebhook',
|
||||||
@ -68,6 +68,8 @@ if TYPE_CHECKING:
|
|||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
MISSING = utils.MISSING
|
||||||
|
|
||||||
|
|
||||||
class DeferredLock:
|
class DeferredLock:
|
||||||
def __init__(self, lock: threading.Lock):
|
def __init__(self, lock: threading.Lock):
|
||||||
@ -333,6 +335,7 @@ class WebhookAdapter:
|
|||||||
route = Route('GET', '/webhooks/{webhook_id}/{webhook_token}', webhook_id=webhook_id, webhook_token=token)
|
route = Route('GET', '/webhooks/{webhook_id}/{webhook_token}', webhook_id=webhook_id, webhook_token=token)
|
||||||
return self.request(route, session=session)
|
return self.request(route, session=session)
|
||||||
|
|
||||||
|
|
||||||
_context = threading.local()
|
_context = threading.local()
|
||||||
_context.adapter = WebhookAdapter()
|
_context.adapter = WebhookAdapter()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user