From 417353da4d77a45ce776f663fbd5e7f8789c7d3a Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 18 Apr 2021 09:07:26 -0400 Subject: [PATCH] Fix up _unique and valid_icon_size implementations --- discord/utils.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/discord/utils.py b/discord/utils.py index 4650cfe7b..bab268252 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -387,10 +387,7 @@ def get(iterable: Iterable[T], **attrs: Any) -> Optional[T]: def _unique(iterable: Iterable[T]) -> List[T]: - seen = set() - adder = seen.add - return [x for x in iterable if not (x in seen or adder(x))] - + return [x for x in dict.fromkeys(iterable)] def _get_as_snowflake(data: Any, key: str) -> Optional[int]: try: @@ -515,7 +512,7 @@ def utcnow() -> datetime.datetime: def valid_icon_size(size: int) -> bool: """Icons must be power of 2 within [16, 4096].""" - return not size & (size - 1) and size in range(16, 4097) + return not size & (size - 1) and 4096 >= size >= 16 class SnowflakeList(array.array):