diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1184f019..8567956f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,4 +22,28 @@ jobs: - uses: astral-sh/ruff-action@v3 with: - version: ${{ steps.ruff-version.outputs.version }} \ No newline at end of file + version: ${{ steps.ruff-version.outputs.version }} + pyright: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [ '3.10', '3.x' ] + name: pyright ${{ matrix.python-version }} + steps: + - uses: actions/checkout@v5 + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" # Cache the pip packages to speed up the workflow + - name: Set up UV + uses: astral-sh/setup-uv@v6 + - name: Install Dependencies and Package + run: uv sync --all-extras + - name: Run Pyright + uses: jakebailey/pyright-action@v2 + with: + version: '1.1.407' + annotate: ${{ matrix.python-version != '3.x' }} + python-path: '.venv/bin/python' \ No newline at end of file diff --git a/fortnite_api/new.py b/fortnite_api/new.py index 5a111e2a..13485778 100644 --- a/fortnite_api/new.py +++ b/fortnite_api/new.py @@ -25,7 +25,7 @@ from __future__ import annotations import datetime -from typing import Any, Generic +from typing import Any, Generic, cast from .abc import ReconstructAble from .cosmetics import ( @@ -208,7 +208,7 @@ def _parse_new_cosmetic( internal_key: str, cosmetic_class: type[CosmeticT], ) -> NewCosmetic[CosmeticT]: - cosmetic_items: list[dict[str, Any]] = get_with_fallback(self._items, internal_key, list) + cosmetic_items = cast(list[dict[str, Any]], get_with_fallback(self._items, internal_key, list)) last_addition_str = self._last_additions[internal_key] last_addition: datetime.datetime | None = last_addition_str and parse_time(last_addition_str) diff --git a/fortnite_api/proxies.py b/fortnite_api/proxies.py index d84c4b77..c33ec9f1 100644 --- a/fortnite_api/proxies.py +++ b/fortnite_api/proxies.py @@ -67,7 +67,7 @@ def _transform_at(self, index: SupportsIndex) -> T: data = super().__getitem__(index) if isinstance(data, dict): # Narrow the type of data to Dict[str, Any] - raw_data: dict[K_co, V_co] = data + raw_data = cast(dict[K_co, V_co], data) result = self._transform_data(raw_data) super().__setitem__(index, result) else: @@ -78,7 +78,7 @@ def _transform_at(self, index: SupportsIndex) -> T: def _transform_all(self): for index, entry in enumerate(self): if isinstance(entry, dict): - raw_data: dict[K_co, V_co] = entry + raw_data = cast(dict[K_co, V_co], entry) result = self._transform_data(raw_data) super().__setitem__(index, result) diff --git a/fortnite_api/utils.py b/fortnite_api/utils.py index 482b4c7d..9a82d232 100644 --- a/fortnite_api/utils.py +++ b/fortnite_api/utils.py @@ -26,7 +26,7 @@ import datetime from collections.abc import Callable -from typing import TYPE_CHECKING, Any, TypeVar +from typing import TYPE_CHECKING, Any, TypeVar, cast K_co = TypeVar('K_co', bound='Hashable', covariant=True) V_co = TypeVar('V_co', covariant=True) @@ -36,7 +36,7 @@ from collections.abc import Hashable try: - import orjson # type: ignore + import orjson _has_orjson: bool = True except ImportError: @@ -201,7 +201,7 @@ def _transform_dict_for_get_request(data: dict[str, Any]) -> dict[str, Any]: updated[key] = str(value).lower() elif isinstance(value, dict): - inner: dict[str, Any] = value # narrow the dict type to pass it along (should always be [str, Any]) + inner = cast(dict[str, Any], value) # narrow the dict type to pass it along (should always be [str, Any]) updated[key] = _transform_dict_for_get_request(inner) if '_' in key: diff --git a/tests/client/test_client_hybrid.py b/tests/client/test_client_hybrid.py index 745a1aeb..bdaf3c64 100644 --- a/tests/client/test_client_hybrid.py +++ b/tests/client/test_client_hybrid.py @@ -27,7 +27,7 @@ import inspect import logging from collections.abc import Callable, Coroutine -from typing import TYPE_CHECKING, Any, Concatenate, Generic, TypeAlias, TypeVar +from typing import TYPE_CHECKING, Any, Concatenate, Generic, TypeAlias, TypeVar, cast import pytest import requests @@ -78,8 +78,8 @@ def _validate_results(self, async_res: T, sync_res: T) -> None: if isinstance(async_res, fortnite_api.ReconstructAble): assert isinstance(sync_res, fortnite_api.ReconstructAble) - sync_res_narrowed: fortnite_api.ReconstructAble[Any, fortnite_api.http.SyncHTTPClient] = sync_res - async_res_narrowed: fortnite_api.ReconstructAble[Any, fortnite_api.http.HTTPClient] = async_res + sync_res_narrowed = cast(fortnite_api.ReconstructAble[Any, fortnite_api.http.SyncHTTPClient], sync_res) + async_res_narrowed = cast(fortnite_api.ReconstructAble[Any, fortnite_api.http.HTTPClient], async_res) async_raw_data = sync_res_narrowed.to_dict() sync_raw_data = sync_res_narrowed.to_dict()