Skip to content

Commit e35fe95

Browse files
committed
fix typing issues
1 parent e22c53c commit e35fe95

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

fortnite_api/new.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from __future__ import annotations
2626

2727
import datetime
28-
from typing import Any, Generic
28+
from typing import Any, Generic, cast
2929

3030
from .abc import ReconstructAble
3131
from .cosmetics import (
@@ -208,7 +208,7 @@ def _parse_new_cosmetic(
208208
internal_key: str,
209209
cosmetic_class: type[CosmeticT],
210210
) -> NewCosmetic[CosmeticT]:
211-
cosmetic_items: list[dict[str, Any]] = get_with_fallback(self._items, internal_key, list)
211+
cosmetic_items = cast(list[dict[str, Any]], get_with_fallback(self._items, internal_key, list))
212212

213213
last_addition_str = self._last_additions[internal_key]
214214
last_addition: datetime.datetime | None = last_addition_str and parse_time(last_addition_str)

fortnite_api/proxies.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _transform_at(self, index: SupportsIndex) -> T:
6767
data = super().__getitem__(index)
6868
if isinstance(data, dict):
6969
# Narrow the type of data to Dict[str, Any]
70-
raw_data: dict[K_co, V_co] = data
70+
raw_data = cast(dict[K_co, V_co], data)
7171
result = self._transform_data(raw_data)
7272
super().__setitem__(index, result)
7373
else:
@@ -78,7 +78,7 @@ def _transform_at(self, index: SupportsIndex) -> T:
7878
def _transform_all(self):
7979
for index, entry in enumerate(self):
8080
if isinstance(entry, dict):
81-
raw_data: dict[K_co, V_co] = entry
81+
raw_data = cast(dict[K_co, V_co], entry)
8282
result = self._transform_data(raw_data)
8383
super().__setitem__(index, result)
8484

fortnite_api/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import datetime
2828
from collections.abc import Callable
29-
from typing import TYPE_CHECKING, Any, TypeVar
29+
from typing import TYPE_CHECKING, Any, TypeVar, cast
3030

3131
K_co = TypeVar('K_co', bound='Hashable', covariant=True)
3232
V_co = TypeVar('V_co', covariant=True)
@@ -201,7 +201,7 @@ def _transform_dict_for_get_request(data: dict[str, Any]) -> dict[str, Any]:
201201
updated[key] = str(value).lower()
202202

203203
elif isinstance(value, dict):
204-
inner: dict[str, Any] = value # narrow the dict type to pass it along (should always be [str, Any])
204+
inner = cast(dict[str, Any], value) # narrow the dict type to pass it along (should always be [str, Any])
205205
updated[key] = _transform_dict_for_get_request(inner)
206206

207207
if '_' in key:

tests/client/test_client_hybrid.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import inspect
2828
import logging
2929
from collections.abc import Callable, Coroutine
30-
from typing import TYPE_CHECKING, Any, Concatenate, Generic, TypeAlias, TypeVar
30+
from typing import TYPE_CHECKING, Any, Concatenate, Generic, TypeAlias, TypeVar, cast
3131

3232
import pytest
3333
import requests
@@ -78,8 +78,8 @@ def _validate_results(self, async_res: T, sync_res: T) -> None:
7878
if isinstance(async_res, fortnite_api.ReconstructAble):
7979
assert isinstance(sync_res, fortnite_api.ReconstructAble)
8080

81-
sync_res_narrowed: fortnite_api.ReconstructAble[Any, fortnite_api.http.SyncHTTPClient] = sync_res
82-
async_res_narrowed: fortnite_api.ReconstructAble[Any, fortnite_api.http.HTTPClient] = async_res
81+
sync_res_narrowed = cast(fortnite_api.ReconstructAble[Any, fortnite_api.http.SyncHTTPClient], sync_res)
82+
async_res_narrowed = cast(fortnite_api.ReconstructAble[Any, fortnite_api.http.HTTPClient], async_res)
8383

8484
async_raw_data = sync_res_narrowed.to_dict()
8585
sync_raw_data = sync_res_narrowed.to_dict()

0 commit comments

Comments
 (0)