Skip to content

Commit c437ebd

Browse files
committed
Move types around
1 parent 4b0d33d commit c437ebd

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

twitchio/ext/commands/bot.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from __future__ import annotations
2626

2727
import logging
28-
from typing import TYPE_CHECKING, Any, Unpack
28+
from typing import TYPE_CHECKING, Any, TypeAlias, Unpack
2929

3030
from twitchio.client import Client
3131

@@ -36,8 +36,9 @@
3636

3737

3838
if TYPE_CHECKING:
39+
from collections.abc import Callable, Coroutine, Iterable
40+
3941
from models.eventsub_ import ChatMessage
40-
from types_.options import Prefix_T
4142

4243
from twitchio.eventsub.subscriptions import SubscriptionPayload
4344
from twitchio.types_.eventsub import SubscriptionResponse
@@ -46,6 +47,8 @@
4647

4748
from .components import Component
4849

50+
PrefixT: TypeAlias = str | Iterable[str] | Callable[["Bot", ChatMessage], Coroutine[Any, Any, str | Iterable[str]]]
51+
4952

5053
logger: logging.Logger = logging.getLogger(__name__)
5154

@@ -154,7 +157,7 @@ def __init__(
154157
client_secret: str,
155158
bot_id: str,
156159
owner_id: str | None = None,
157-
prefix: Prefix_T,
160+
prefix: PrefixT,
158161
**options: Unpack[ClientOptions],
159162
) -> None:
160163
super().__init__(
@@ -165,7 +168,7 @@ def __init__(
165168
)
166169

167170
self._owner_id: str | None = owner_id
168-
self._get_prefix: Prefix_T = prefix
171+
self._get_prefix: PrefixT = prefix
169172
self._components: dict[str, Component] = {}
170173
self._base_converter: _BaseConverter = _BaseConverter(self)
171174

twitchio/ext/commands/context.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from __future__ import annotations
2626

2727
from collections.abc import Iterable
28-
from typing import TYPE_CHECKING, Any, Literal
28+
from typing import TYPE_CHECKING, Any, Literal, TypeAlias
2929

3030
from twitchio.ext.commands.core import CommandErrorPayload
3131

@@ -37,15 +37,18 @@
3737

3838

3939
if TYPE_CHECKING:
40+
from collections.abc import Callable, Coroutine
41+
4042
from models import SentMessage
4143
from models.eventsub_ import ChatMessage
42-
from types_.options import Prefix_T
4344
from user import Chatter, PartialUser
4445

4546
from .bot import Bot
4647
from .components import Component
4748
from .core import Command
4849

50+
PrefixT: TypeAlias = str | Iterable[str] | Callable[[Bot, ChatMessage], Coroutine[Any, Any, str | Iterable[str]]]
51+
4952

5053
class Context:
5154
"""The Context class constructed when a message is received and processed via the :func:`~twitchio.event_message`
@@ -241,7 +244,7 @@ def _validate_prefix(self, potential: str | Iterable[str]) -> None:
241244
return
242245

243246
async def _get_prefix(self) -> None:
244-
assigned: Prefix_T = self._bot._get_prefix
247+
assigned: PrefixT = self._bot._get_prefix
245248
potential: str | Iterable[str]
246249

247250
if callable(assigned):

twitchio/types_/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,3 @@
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
2323
"""
24-
25-
from .options import *

twitchio/types_/options.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,15 @@
2222
SOFTWARE.
2323
"""
2424

25-
from collections.abc import Callable, Coroutine, Iterable
25+
from collections.abc import Callable, Coroutine
2626
from typing import Any, NotRequired, TypeAlias, TypedDict
2727

2828
import aiohttp
2929

3030
from ..authentication import Scopes
31-
from ..ext.commands import Bot
32-
from ..models import ChatMessage
3331
from ..web import *
3432

3533

36-
__all__ = ("AdapterOT", "ClientOptions", "WaitPredicateT", "Prefix_T")
37-
38-
3934
AdapterOT: TypeAlias = type[StarletteAdapter | AiohttpAdapter] | StarletteAdapter | AiohttpAdapter
4035

4136

@@ -47,4 +42,3 @@ class ClientOptions(TypedDict, total=False):
4742

4843

4944
WaitPredicateT = Callable[..., Coroutine[Any, Any, bool]]
50-
Prefix_T = str | Iterable[str] | Callable[[Bot, ChatMessage], Coroutine[Any, Any, str | Iterable[str]]]

0 commit comments

Comments
 (0)