From a0c019330298827a5c9be49314cc48a0008a9c2e Mon Sep 17 00:00:00 2001 From: junah201 Date: Wed, 3 Jul 2024 04:17:57 +0900 Subject: [PATCH 1/2] Fix invalid type hinting of initial_channels in WS Connection (#460) --- twitchio/client.py | 2 +- twitchio/ext/commands/bot.py | 4 ++-- twitchio/websocket.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/twitchio/client.py b/twitchio/client.py index 97460d06..cc9c09df 100644 --- a/twitchio/client.py +++ b/twitchio/client.py @@ -76,7 +76,7 @@ def __init__( token: str, *, client_secret: str = None, - initial_channels: Union[list, tuple, Callable] = None, + initial_channels: Union[List[str], Tuple[str, ...], Callable[[], Union[List[str], Tuple[str, ...]]], None] = None, loop: asyncio.AbstractEventLoop = None, heartbeat: Optional[float] = 30.0, retain_cache: Optional[bool] = True, diff --git a/twitchio/ext/commands/bot.py b/twitchio/ext/commands/bot.py index 942839d4..8e7ff049 100644 --- a/twitchio/ext/commands/bot.py +++ b/twitchio/ext/commands/bot.py @@ -31,7 +31,7 @@ import types import warnings from functools import partial -from typing import Callable, Optional, Union, Coroutine, Dict, List, TYPE_CHECKING, Mapping, Awaitable +from typing import Callable, Optional, Union, Coroutine, Dict, List, Tuple, TYPE_CHECKING, Mapping, Awaitable from twitchio.client import Client from twitchio.http import TwitchHTTP @@ -53,7 +53,7 @@ def __init__( *, prefix: Union[str, list, tuple, set, Callable, Coroutine], client_secret: str = None, - initial_channels: Union[list, tuple, Callable] = None, + initial_channels: Union[List[str], Tuple[str, ...], Callable[[], Union[List[str], Tuple[str, ...]]], None] = None, heartbeat: Optional[float] = 30.0, retain_cache: Optional[bool] = True, **kwargs, diff --git a/twitchio/websocket.py b/twitchio/websocket.py index da61a6a1..085486b7 100644 --- a/twitchio/websocket.py +++ b/twitchio/websocket.py @@ -31,7 +31,7 @@ import time import traceback from functools import partial -from typing import Union, Optional, List, TYPE_CHECKING +from typing import Union, Callable, Optional, List, Tuple, TYPE_CHECKING import aiohttp @@ -57,7 +57,7 @@ def __init__( client: "Client", token: str = None, modes: tuple = None, - initial_channels: List[str] = None, + initial_channels: Union[List[str], Tuple[str, ...], Callable[[], Union[List[str], Tuple[str, ...]]], None] = None, retain_cache: Optional[bool] = True, ): self._loop = loop From dea20626cacf4458d6ddcc62a3d2c7c8e3d039ad Mon Sep 17 00:00:00 2001 From: junah201 Date: Thu, 4 Jul 2024 20:26:32 +0900 Subject: [PATCH 2/2] Fix linting --- twitchio/client.py | 4 +++- twitchio/ext/commands/bot.py | 4 +++- twitchio/websocket.py | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/twitchio/client.py b/twitchio/client.py index cc9c09df..de3b2632 100644 --- a/twitchio/client.py +++ b/twitchio/client.py @@ -76,7 +76,9 @@ def __init__( token: str, *, client_secret: str = None, - initial_channels: Union[List[str], Tuple[str, ...], Callable[[], Union[List[str], Tuple[str, ...]]], None] = None, + initial_channels: Union[ + List[str], Tuple[str, ...], Callable[[], Union[List[str], Tuple[str, ...]]], None + ] = None, loop: asyncio.AbstractEventLoop = None, heartbeat: Optional[float] = 30.0, retain_cache: Optional[bool] = True, diff --git a/twitchio/ext/commands/bot.py b/twitchio/ext/commands/bot.py index 8e7ff049..e5378685 100644 --- a/twitchio/ext/commands/bot.py +++ b/twitchio/ext/commands/bot.py @@ -53,7 +53,9 @@ def __init__( *, prefix: Union[str, list, tuple, set, Callable, Coroutine], client_secret: str = None, - initial_channels: Union[List[str], Tuple[str, ...], Callable[[], Union[List[str], Tuple[str, ...]]], None] = None, + initial_channels: Union[ + List[str], Tuple[str, ...], Callable[[], Union[List[str], Tuple[str, ...]]], None + ] = None, heartbeat: Optional[float] = 30.0, retain_cache: Optional[bool] = True, **kwargs, diff --git a/twitchio/websocket.py b/twitchio/websocket.py index 085486b7..c580a979 100644 --- a/twitchio/websocket.py +++ b/twitchio/websocket.py @@ -57,7 +57,9 @@ def __init__( client: "Client", token: str = None, modes: tuple = None, - initial_channels: Union[List[str], Tuple[str, ...], Callable[[], Union[List[str], Tuple[str, ...]]], None] = None, + initial_channels: Union[ + List[str], Tuple[str, ...], Callable[[], Union[List[str], Tuple[str, ...]]], None + ] = None, retain_cache: Optional[bool] = True, ): self._loop = loop