Skip to content

Commit 39ebdd6

Browse files
committed
Cleanup adapter typing/logic in Client
1 parent 0752b51 commit 39ebdd6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

twitchio/client.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import math
3030
from collections import defaultdict
3131
from types import MappingProxyType
32-
from typing import TYPE_CHECKING, Any, Literal, NamedTuple, Self, Unpack, cast, overload
32+
from typing import TYPE_CHECKING, Any, Literal, NamedTuple, Self, Unpack, overload
3333

3434
from .authentication import ManagedHTTPClient, Scopes, UserTokenPayload
3535
from .eventsub.enums import SubscriptionType
@@ -149,15 +149,17 @@ def __init__(
149149
msg = "If you require the StarletteAdapter please install the required packages: 'pip install twitchio[starlette]'."
150150
logger.warning(msg)
151151

152-
adapter: BaseAdapter[Any] | type[BaseAdapter[Any]] | type[AiohttpAdapter[Self]] = options.get(
153-
"adapter", AiohttpAdapter
154-
)
152+
self._adapter: BaseAdapter[Any] | AiohttpAdapter[Self]
153+
adapter: BaseAdapter[Any] | type[BaseAdapter[Any]] | None = options.get("adapter")
154+
155155
if isinstance(adapter, BaseAdapter):
156-
adapter.client = self
157156
self._adapter = adapter
157+
elif adapter is None:
158+
self._adapter = AiohttpAdapter()
158159
else:
159-
self._adapter = cast("AiohttpAdapter[Self]", adapter())
160-
self._adapter.client = self
160+
self._adapter = adapter()
161+
162+
self._adapter.client = self
161163

162164
# Own Client User. Set in login...
163165
self._fetch_self: bool = options.get("fetch_client_user", True)

0 commit comments

Comments
 (0)