Skip to content

Commit cdef532

Browse files
committed
ok, now it's optional
1 parent e4d3805 commit cdef532

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

mystbin/client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
import asyncio
2626
import json
27-
from typing import Awaitable, Callable, Optional, Union, TYPE_CHECKING
27+
from typing import TYPE_CHECKING, Awaitable, Callable, Optional, Type, Union
28+
2829
if TYPE_CHECKING:
2930
import requests
3031

@@ -56,15 +57,15 @@ def __init__(
5657
self, *,
5758
api_key: str = None,
5859
session: Optional[Union[aiohttp.ClientSession,
59-
requests.Session]] = None
60+
Type["requests.Session"]]] = None
6061
) -> None:
6162
self.api_key = api_key
6263
self._are_we_async = session is None or isinstance(
6364
session, aiohttp.ClientSession)
6465
self.session = self._generate_sync_session(
6566
session) if not self._are_we_async else None
6667

67-
def _generate_sync_session(self, session: requests.Session) -> requests.Session:
68+
def _generate_sync_session(self, session: Type["requests.Session"]) -> Type["requests.Session"]:
6869
""" We will update a :class:`requests.Session` instance with the auth we require. """
6970
# the passed session was found to be 'sync'.
7071
if self.api_key:
@@ -100,7 +101,7 @@ def post(self, content: str, syntax: str = None) -> Union[Paste, Awaitable]:
100101
def _perform_sync_post(self, content: str, syntax: str = None) -> Paste:
101102
""" Sync post request. """
102103
payload = {'meta': [{'index': 0, 'syntax': syntax}]}
103-
response: requests.Response = self.session.post(API_BASE_URL, files={
104+
response: Type["requests.Response"] = self.session.post(API_BASE_URL, files={
104105
'data': content, 'meta': (None, json.dumps(payload), 'application/json')}, timeout=CLIENT_TIMEOUT)
105106
if response.status_code not in [200, 201]:
106107
raise APIError(response.status_code, response.text)

0 commit comments

Comments
 (0)