1313 HTTP_UNAUTHORIZED ,
1414 RATING_DICT ,
1515 STEAM_USER_ID_LENGTH ,
16+ AntiCheatAPIResponse ,
1617 AntiCheatData ,
1718 AntiCheatStatus ,
1819 Game ,
20+ ProtonDBAPIResponse ,
1921 Response ,
22+ SteamAPINameResolutionResponse ,
23+ SteamAPIPlatformsResponse ,
24+ SteamAPIUserDataResponse ,
2025 SteamUserData ,
2126)
2227from vapor .exceptions import InvalidIDError , PrivateAccountError , UnauthorizedError
2328
2429
25- async def async_get (url : str , ** session_kwargs : Any ) -> Response :
30+ async def async_get (url : str , ** session_kwargs : Any ) -> Response : # pyright: ignore[reportAny]
2631 """Async get request for fetching web content.
2732
2833 Args:
@@ -32,7 +37,7 @@ async def async_get(url: str, **session_kwargs: Any) -> Response:
3237 Returns:
3338 Response: A Response object containing the body and status code.
3439 """
35- async with aiohttp .ClientSession (** session_kwargs ) as session , session .get (
40+ async with aiohttp .ClientSession (** session_kwargs ) as session , session .get ( # pyright: ignore[reportAny]
3641 url ,
3742 ) as response :
3843 return Response (data = await response .text (), status = response .status )
@@ -53,16 +58,19 @@ async def check_game_is_native(app_id: str) -> bool:
5358 if data .status != HTTP_SUCCESS :
5459 return False
5560
56- json_data = json .loads (data .data )
61+ json_data : Dict [ str , SteamAPIPlatformsResponse ] = json .loads (data .data )
5762
5863 return _extract_game_is_native (json_data , app_id )
5964
6065
61- def _extract_game_is_native (data : Dict , app_id : str ) -> bool :
66+ def _extract_game_is_native (
67+ data : Dict [str , SteamAPIPlatformsResponse ],
68+ app_id : str ,
69+ ) -> bool :
6270 """Extract whether or not a game is Linux native from API data.
6371
6472 Args:
65- data (Dict): the data from the Steam API.
73+ data (Dict[str, SteamAPIPlatformsResponse] ): the data from the Steam API.
6674 app_id (str): The App ID of the game
6775
6876 Returns:
@@ -98,7 +106,7 @@ async def get_anti_cheat_data() -> Optional[Cache]:
98106 return None
99107
100108 try :
101- anti_cheat_data = json .loads (data .data )
109+ anti_cheat_data : List [ AntiCheatAPIResponse ] = json .loads (data .data )
102110 except json .JSONDecodeError :
103111 return None
104112
@@ -109,11 +117,11 @@ async def get_anti_cheat_data() -> Optional[Cache]:
109117 return cache
110118
111119
112- def parse_anti_cheat_data (data : List [Dict ]) -> List [AntiCheatData ]:
120+ def parse_anti_cheat_data (data : List [AntiCheatAPIResponse ]) -> List [AntiCheatData ]:
113121 """Parse and return data from AreWeAntiCheatYet.
114122
115123 Args:
116- data (List[Dict ]): The data from AreWeAntiCheatYet
124+ data (List[AntiCheatAPIResponse ]): The data from AreWeAntiCheatYet
117125
118126 Returns:
119127 List[AntiCheatData]: the anticheat statuses of each game in the given data
@@ -152,7 +160,7 @@ async def get_game_average_rating(app_id: str, cache: Cache) -> str:
152160 if data .status != HTTP_SUCCESS :
153161 return 'pending'
154162
155- json_data = json .loads (data .data )
163+ json_data : ProtonDBAPIResponse = json .loads (data .data )
156164
157165 return json_data .get ('tier' , 'pending' )
158166
@@ -178,7 +186,7 @@ async def resolve_vanity_name(api_key: str, name: str) -> str:
178186 if data .status == HTTP_FORBIDDEN :
179187 raise UnauthorizedError
180188
181- user_data = json .loads (data .data )
189+ user_data : SteamAPINameResolutionResponse = json .loads (data .data )
182190 if 'response' not in user_data or user_data ['response' ]['success' ] != 1 :
183191 raise InvalidIDError
184192
@@ -218,19 +226,19 @@ async def get_steam_user_data(api_key: str, user_id: str) -> SteamUserData:
218226 if data .status == HTTP_UNAUTHORIZED :
219227 raise UnauthorizedError
220228
221- data = json .loads (data .data )
229+ user_data : SteamAPIUserDataResponse = json .loads (data .data )
222230
223- return await parse_steam_user_games (data , cache )
231+ return await parse_steam_user_games (user_data , cache )
224232
225233
226234async def parse_steam_user_games (
227- data : Dict ,
235+ data : SteamAPIUserDataResponse ,
228236 cache : Cache ,
229237) -> SteamUserData :
230238 """Parse user data from the Steam API and return information on their games.
231239
232240 Args:
233- data (Dict ): user data from the Steam API
241+ data (SteamAPIUserDataResponse ): user data from the Steam API
234242 cache (Cache): the loaded Cache file
235243
236244 Returns:
@@ -240,12 +248,12 @@ async def parse_steam_user_games(
240248 PrivateAccountError: if `games` is not present in `data['response']`
241249 (the user's account was found but is private)
242250 """
243- data = data ['response' ]
251+ game_data = data ['response' ]
244252
245- if 'games' not in data :
253+ if 'games' not in game_data :
246254 raise PrivateAccountError
247255
248- games = data ['games' ]
256+ games = game_data ['games' ]
249257 game_ratings = [
250258 Game (
251259 name = game ['name' ],
0 commit comments