Skip to content

Commit 4f9fd6d

Browse files
Fix suggestions
1 parent b47e85d commit 4f9fd6d

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

utils/msl/memberships.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from utils import GLOBAL_SSL_CONTEXT
1414

1515
if TYPE_CHECKING:
16-
from collections.abc import Mapping, MutableMapping, Sequence
16+
from collections.abc import Mapping, Sequence
1717
from http.cookies import Morsel
1818
from logging import Logger
1919
from typing import Final
@@ -29,16 +29,14 @@
2929

3030
logger: "Final[Logger]" = logging.getLogger("TeX-Bot")
3131

32-
SU_PLATFORM_ACCESS_COOKIE: "Final[str]" = settings["SU_PLATFORM_ACCESS_COOKIE"]
33-
34-
BASE_SU_PLATFORM_WEB_HEADERS: "Final[Mapping[str, str]]" = {
32+
BASE_SU_PLATFORM_WEB_HEADERS: "Mapping[str, str]" = {
3533
"Cache-Control": "no-cache",
3634
"Pragma": "no-cache",
3735
"Expires": "0",
3836
}
3937

40-
BASE_SU_PLATFORM_WEB_COOKIES: "Final[MutableMapping[str, str]]" = {
41-
".AspNet.SharedCookie": SU_PLATFORM_ACCESS_COOKIE,
38+
BASE_SU_PLATFORM_WEB_COOKIES: "Mapping[str, str]" = {
39+
".AspNet.SharedCookie": settings["SU_PLATFORM_ACCESS_COOKIE"],
4240
}
4341

4442
MEMBERS_LIST_URL: "Final[str]" = f"https://guildofstudents.com/organisation/memberlist/{settings['ORGANISATION_ID']}/?sort=groups"
@@ -48,20 +46,23 @@
4846

4947
async def fetch_url_content_with_session(url: str) -> str:
5048
"""Fetch the HTTP content at the given URL, using a shared aiohttp session."""
49+
global BASE_SU_PLATFORM_WEB_COOKIES # noqa: PLW0603
5150
async with (
5251
aiohttp.ClientSession(
5352
headers=BASE_SU_PLATFORM_WEB_HEADERS, cookies=BASE_SU_PLATFORM_WEB_COOKIES
5453
) as http_session,
5554
http_session.get(url=url, ssl=GLOBAL_SSL_CONTEXT) as http_response,
5655
):
57-
returned_asp_cookie: Morsel | None = http_response.cookies.get(".AspNet.SharedCookie") # type: ignore[type-arg]
56+
returned_asp_cookie: Morsel[str] | None = http_response.cookies.get(".AspNet.SharedCookie")
5857
if (
59-
returned_asp_cookie
58+
returned_asp_cookie is not None
6059
and returned_asp_cookie.value
6160
!= BASE_SU_PLATFORM_WEB_COOKIES[".AspNet.SharedCookie"]
6261
):
6362
logger.info("SU platform access cookie was updated by the server; updating local.")
64-
BASE_SU_PLATFORM_WEB_COOKIES[".AspNet.SharedCookie"] = returned_asp_cookie.value
63+
BASE_SU_PLATFORM_WEB_COOKIES = {
64+
".AspNet.SharedCookie": returned_asp_cookie.value,
65+
}
6566
return await http_response.text()
6667

6768

0 commit comments

Comments
 (0)