Skip to content

Commit ddb6759

Browse files
committed
Temp Fix pyright issues until base class is propery implemented.
1 parent 5a7d9dc commit ddb6759

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

twitchio/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
from .models.streams import Stream, VideoMarkers
6565
from .models.videos import Video
6666
from .types_.eventsub import SubscriptionCreateTransport, SubscriptionResponse, _SubscriptionData
67-
from .types_.options import AdapterOT, ClientOptions, WaitPredicateT
67+
from .types_.options import ClientOptions, WaitPredicateT
6868
from .types_.tokens import TokenMappingData
6969

7070

@@ -134,7 +134,7 @@ def __init__(
134134
scopes=scopes,
135135
session=session,
136136
)
137-
adapter: AdapterOT = options.get("adapter", AiohttpAdapter)
137+
adapter: BaseAdapter | type[BaseAdapter] = options.get("adapter", AiohttpAdapter)
138138
if isinstance(adapter, BaseAdapter):
139139
adapter.client = self
140140
self._adapter = adapter

twitchio/types_/options.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,19 @@
2323
"""
2424

2525
from collections.abc import Callable, Coroutine
26-
from typing import Any, NotRequired, TypeAlias, TypedDict
26+
from typing import Any, NotRequired, TypedDict
2727

2828
import aiohttp
2929

3030
from ..authentication import Scopes
31-
from ..web import AiohttpAdapter
32-
33-
try:
34-
from ..web import StarletteAdapter as StarletteAdapter
35-
36-
has_starlette = True
37-
except ImportError:
38-
has_starlette = False
39-
40-
41-
if has_starlette:
42-
AdapterOT: TypeAlias = type[StarletteAdapter | AiohttpAdapter] | StarletteAdapter | AiohttpAdapter # type: ignore
43-
else:
44-
AdapterOT: TypeAlias = type[AiohttpAdapter] | AiohttpAdapter # type: ignore
31+
from ..web.utils import BaseAdapter
4532

4633

4734
class ClientOptions(TypedDict, total=False):
4835
redirect_uri: str | None
4936
scopes: Scopes | None
5037
session: aiohttp.ClientSession | None
51-
adapter: NotRequired[AdapterOT] # type: ignore
38+
adapter: NotRequired[BaseAdapter]
5239

5340

5441
WaitPredicateT = Callable[..., Coroutine[Any, Any, bool]]

twitchio/web/utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@
3434

3535

3636
if TYPE_CHECKING:
37+
import asyncio
38+
3739
from starlette.requests import Request
3840

41+
from ..client import Client
3942
from ..types_.eventsub import EventSubHeaders
4043

4144

@@ -46,6 +49,10 @@
4649

4750

4851
class BaseAdapter(abc.ABC):
52+
client: Client
53+
_runner_task: asyncio.Task[None] | None
54+
_eventsub_secret: str | None
55+
4956
@abc.abstractmethod
5057
async def event_startup(self) -> None: ...
5158

@@ -70,6 +77,14 @@ async def oauth_callback(self, request: Any) -> Any: ...
7077
@abc.abstractmethod
7178
async def oauth_redirect(self, request: Any) -> Any: ...
7279

80+
@property
81+
@abc.abstractmethod
82+
def eventsub_url(self) -> str: ...
83+
84+
@property
85+
@abc.abstractmethod
86+
def redirect_url(self) -> str: ...
87+
7388

7489
async def verify_message(*, request: Request | web.Request, secret: str) -> bytes:
7590
body: bytes

0 commit comments

Comments
 (0)