From b9ec517ad35a6f7022a485ac652b6d951e360064 Mon Sep 17 00:00:00 2001 From: Goldy <66202304+THEGOLDENPRO@users.noreply.github.com> Date: Mon, 25 Nov 2024 22:47:15 +0000 Subject: [PATCH] refactor: rename `SnowflakeT` --- anmoku/clients/async_.py | 6 +++--- anmoku/clients/base.py | 4 ++-- anmoku/clients/sync.py | 6 +++--- anmoku/typing/anmoku.py | 6 ++++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/anmoku/clients/async_.py b/anmoku/clients/async_.py index 10debbe..c8e42d4 100644 --- a/anmoku/clients/async_.py +++ b/anmoku/clients/async_.py @@ -4,7 +4,7 @@ if TYPE_CHECKING: from typing import Any, Optional, Type, Dict, Tuple - from ..typing.anmoku import SnowflakeT + from ..typing.anmoku import StrOrIntT from ..typing.jikan import SearchResultData from .base import ( @@ -66,10 +66,10 @@ async def get(self, resource: Type[NoArgsResourceGenericT]) -> NoArgsResourceGen ... @overload - async def get(self, resource: Type[ResourceGenericT], id: SnowflakeT, **kwargs) -> ResourceGenericT: + async def get(self, resource: Type[ResourceGenericT], id: StrOrIntT, **kwargs) -> ResourceGenericT: ... - async def get(self, resource: Type[ResourceGenericT], id: Optional[SnowflakeT] = None, **kwargs) -> ResourceGenericT: + async def get(self, resource: Type[ResourceGenericT], id: Optional[StrOrIntT] = None, **kwargs) -> ResourceGenericT: """Get's the exact resource typically by id.""" if id is not None: kwargs["id"] = id diff --git a/anmoku/clients/base.py b/anmoku/clients/base.py index 9fb278e..2700acd 100644 --- a/anmoku/clients/base.py +++ b/anmoku/clients/base.py @@ -5,7 +5,7 @@ from typing import Any, Mapping, TypeVar, Type, Optional from .. import resources - from ..typing.anmoku import SnowflakeT + from ..typing.anmoku import StrOrIntT from ..resources.helpers import SearchResult ResourceGenericT = TypeVar( @@ -70,7 +70,7 @@ def __init__(self, debug: bool = False) -> None: super().__init__() @abstractmethod - def get(self, resource: Type[ResourceGenericT], id: Optional[SnowflakeT] = None, **kwargs) -> ResourceGenericT: + def get(self, resource: Type[ResourceGenericT], id: Optional[StrOrIntT] = None, **kwargs) -> ResourceGenericT: """Get's the exact resource by id.""" ... diff --git a/anmoku/clients/sync.py b/anmoku/clients/sync.py index f0e36c2..5493eec 100644 --- a/anmoku/clients/sync.py +++ b/anmoku/clients/sync.py @@ -4,7 +4,7 @@ if TYPE_CHECKING: from typing import Any, Optional, Type, Tuple - from ..typing.anmoku import SnowflakeT + from ..typing.anmoku import StrOrIntT from ..typing.jikan import SearchResultData from .base import ( @@ -64,10 +64,10 @@ def get(self, resource: Type[NoArgsResourceGenericT]) -> NoArgsResourceGenericT: ... @overload - def get(self, resource: Type[ResourceGenericT], id: SnowflakeT, **kwargs) -> ResourceGenericT: + def get(self, resource: Type[ResourceGenericT], id: StrOrIntT, **kwargs) -> ResourceGenericT: ... - def get(self, resource: Type[ResourceGenericT], id: Optional[SnowflakeT] = None, **kwargs) -> ResourceGenericT: + def get(self, resource: Type[ResourceGenericT], id: Optional[StrOrIntT] = None, **kwargs) -> ResourceGenericT: """Get's the exact resource typically by id.""" if id is not None: kwargs["id"] = id diff --git a/anmoku/typing/anmoku.py b/anmoku/typing/anmoku.py index f122ef3..db9996b 100644 --- a/anmoku/typing/anmoku.py +++ b/anmoku/typing/anmoku.py @@ -1,5 +1,7 @@ from __future__ import annotations from typing import Union -# TODO: tf, that's not what a snowflake is, what was I on. Rename this. -SnowflakeT = Union[str, int] \ No newline at end of file +StrOrIntT = Union[str, int] +""" +StrOrIntT can be either a number (int) or string. Commonly used in methods that accept ID. +""" \ No newline at end of file