aboutsummaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-04-18 09:07:26 -0400
committerRapptz <[email protected]>2021-04-18 09:07:26 -0400
commit417353da4d77a45ce776f663fbd5e7f8789c7d3a (patch)
tree608d00130943189e94a2be5dbcc7f9d25583d4bb /discord
parentAdd typings for discord.utils (diff)
downloaddiscord.py-417353da4d77a45ce776f663fbd5e7f8789c7d3a.tar.xz
discord.py-417353da4d77a45ce776f663fbd5e7f8789c7d3a.zip
Fix up _unique and valid_icon_size implementations
Diffstat (limited to 'discord')
-rw-r--r--discord/utils.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/discord/utils.py b/discord/utils.py
index 4650cfe7..bab26825 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):