From 5fa64e83e0ba8f3e49047d6914b4ecb24fb20ffc Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 13 May 2021 10:24:28 +1000 Subject: [PATCH] Fix issues with imports causing NameErrors --- discord/abc.py | 4 ++-- discord/guild.py | 9 ++++++--- discord/member.py | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/discord/abc.py b/discord/abc.py index a785e35dd..5471b336b 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -63,6 +63,8 @@ if TYPE_CHECKING: from .embeds import Embed from .message import Message, MessageReference + SnowflakeTime = Union["Snowflake", datetime] + MISSING = utils.MISSING @@ -98,8 +100,6 @@ class Snowflake(Protocol): """:class:`datetime.datetime`: Returns the model's creation time as an aware datetime in UTC.""" raise NotImplementedError -SnowflakeTime = Union[Snowflake, datetime] - @runtime_checkable class User(Snowflake, Protocol): """An ABC that details the common operations on a Discord user. diff --git a/discord/guild.py b/discord/guild.py index b8ba0ddd5..1d5baf505 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -22,6 +22,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +from __future__ import annotations + import copy from collections import namedtuple from typing import Dict, List, Literal, Optional, TYPE_CHECKING, Union, overload @@ -50,6 +52,7 @@ __all__ = ( ) if TYPE_CHECKING: + from .abc import SnowflakeTime from .types.guild import ( Ban as BanPayload ) @@ -1352,7 +1355,7 @@ class Guild(Hashable): return [convert(d) for d in data] - def fetch_members(self, *, limit: int = 1000, after: Optional[abc.SnowflakeTime] = None) -> List[Member]: + def fetch_members(self, *, limit: int = 1000, after: Optional[SnowflakeTime] = None) -> List[Member]: """Retrieves an :class:`.AsyncIterator` that enables receiving the guild's members. In order to use this, :meth:`Intents.members` must be enabled. @@ -2221,8 +2224,8 @@ class Guild(Hashable): self, *, limit: int = 100, - before: Optional[abc.SnowflakeTime] = None, - after: Optional[abc.SnowflakeTime] = None, + before: Optional[SnowflakeTime] = None, + after: Optional[SnowflakeTime] = None, oldest_first: Optional[bool] = None, user: abc.Snowflake = None, action: AuditLogAction = None diff --git a/discord/member.py b/discord/member.py index 008de3650..fcb2eef0b 100644 --- a/discord/member.py +++ b/discord/member.py @@ -22,6 +22,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +from __future__ import annotations + import datetime import inspect import itertools