Skip to content

Commit 4afe54a

Browse files
committed
♻️ move valid_icon_size to asset.py
1 parent 295ed46 commit 4afe54a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

discord/asset.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
MISSING = utils.MISSING
4848

4949

50+
def _valid_icon_size(size: int) -> bool:
51+
"""Icons must be power of 2 within [16, 4096]."""
52+
return not size & (size - 1) and 4096 >= size >= 16
53+
54+
5055
class AssetMixin:
5156
url: str
5257
_state: Any | None
@@ -371,7 +376,7 @@ def replace(
371376
url = url.with_path(f"{path}.{static_format}")
372377

373378
if size is not MISSING:
374-
if not utils.valid_icon_size(size):
379+
if not _valid_icon_size(size):
375380
raise InvalidArgument("size must be a power of 2 between 16 and 4096")
376381
url = url.with_query(size=size)
377382
else:
@@ -398,7 +403,7 @@ def with_size(self, size: int, /) -> Asset:
398403
InvalidArgument
399404
The asset had an invalid size.
400405
"""
401-
if not utils.valid_icon_size(size):
406+
if not _valid_icon_size(size):
402407
raise InvalidArgument("size must be a power of 2 between 16 and 4096")
403408

404409
url = str(yarl.URL(self._url).with_query(size=size))

discord/utils/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,6 @@ def get_slots(cls: type[Any]) -> Iterator[str]:
318318
continue
319319

320320

321-
def valid_icon_size(size: int) -> bool:
322-
"""Icons must be power of 2 within [16, 4096]."""
323-
return not size & (size - 1) and 4096 >= size >= 16
324-
325-
326321
class SnowflakeList(array.array):
327322
"""Internal data storage class to efficiently store a list of snowflakes.
328323

0 commit comments

Comments
 (0)