Skip to content

Commit a27fd97

Browse files
committed
header and broken type
1 parent fb1e2ca commit a27fd97

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mystbin/client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ def _generate_sync_session(self, session: Type["requests.Session"]) -> Type["req
6868
""" We will update a :class:`requests.Session` instance with the auth we require. """
6969
# the passed session was found to be 'sync'.
7070
if self.api_key:
71-
session.headers.update({"Authorization": self.api_key})
71+
session.headers.update(
72+
{"Authorization": self.api_key, "User-Agent": "Mystbin.py"})
7273
return session
7374

7475
async def _generate_async_session(self, session: Optional[aiohttp.ClientSession] = None) -> aiohttp.ClientSession:
@@ -77,7 +78,7 @@ async def _generate_async_session(self, session: Optional[aiohttp.ClientSession]
7778
session = aiohttp.ClientSession(raise_for_status=False)
7879
if self.api_key:
7980
session._default_headers.update(
80-
{"Authorization": self.api_key})
81+
{"Authorization": self.api_key, "User-Agent": "Mystbin.py"})
8182
session._timeout = aiohttp.ClientTimeout(CLIENT_TIMEOUT)
8283
return session
8384

@@ -148,7 +149,7 @@ def get(self, paste_id: str) -> Union[PasteData, Awaitable]:
148149

149150
def _perform_sync_get(self, paste_id: str, syntax: str = None) -> PasteData:
150151
""" Sync get request. """
151-
response: requests.Response = self.session.get(
152+
response: Type["requests.Response"] = self.session.get(
152153
f"{API_BASE_URL}/{paste_id}", timeout=CLIENT_TIMEOUT)
153154
if response.status_code not in (200, ):
154155
raise BadPasteID("This is an invalid Mystb.in paste ID.")

0 commit comments

Comments
 (0)