From 8d60f18de611b4efe5a09dc0765e4e115184597c Mon Sep 17 00:00:00 2001 From: Lucas Hardt Date: Sun, 19 Oct 2025 17:08:05 +0200 Subject: [PATCH 1/5] Implement new pyright workflow --- .github/workflows/lint.yml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1184f019..58f2340e 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@v1 + with: + version: '1.1.394' + warnings: false + no-comments: ${{ matrix.python-version != '3.x' }} \ No newline at end of file From e35fe9578f8af1b236beac0d377321141641259c Mon Sep 17 00:00:00 2001 From: Lucas Hardt Date: Wed, 29 Oct 2025 16:17:32 +0100 Subject: [PATCH 2/5] fix typing issues --- fortnite_api/new.py | 4 ++-- fortnite_api/proxies.py | 4 ++-- fortnite_api/utils.py | 4 ++-- tests/client/test_client_hybrid.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) 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..cfee9ec9 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) @@ -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() From 65470a3d8392545402e9dfc2f6efb5b2bd67955b Mon Sep 17 00:00:00 2001 From: Lucas Hardt Date: Fri, 31 Oct 2025 00:16:32 +0100 Subject: [PATCH 3/5] update pyright action --- .github/workflows/lint.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 58f2340e..a481e1c8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -42,8 +42,8 @@ jobs: - name: Install Dependencies and Package run: uv sync --all-extras - name: Run Pyright - uses: jakebailey/pyright-action@v1 + uses: jakebailey/pyright-action@v2 with: - version: '1.1.394' - warnings: false - no-comments: ${{ matrix.python-version != '3.x' }} \ No newline at end of file + version: '1.1.407' + annotate: ${{ matrix.python-version != '3.x' }} + venv-path: .venv \ No newline at end of file From 1ce40e8235f0506ffc11fab1235541e43ce65480 Mon Sep 17 00:00:00 2001 From: Lucas Hardt Date: Fri, 31 Oct 2025 00:24:21 +0100 Subject: [PATCH 4/5] update python path --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a481e1c8..8567956f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -46,4 +46,4 @@ jobs: with: version: '1.1.407' annotate: ${{ matrix.python-version != '3.x' }} - venv-path: .venv \ No newline at end of file + python-path: '.venv/bin/python' \ No newline at end of file From c58b0dfaa89211f3947b3c064fdabe1adc35fa23 Mon Sep 17 00:00:00 2001 From: Lucas Hardt Date: Fri, 31 Oct 2025 00:29:49 +0100 Subject: [PATCH 5/5] remove unncessary type ignore --- fortnite_api/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortnite_api/utils.py b/fortnite_api/utils.py index cfee9ec9..9a82d232 100644 --- a/fortnite_api/utils.py +++ b/fortnite_api/utils.py @@ -36,7 +36,7 @@ from collections.abc import Hashable try: - import orjson # type: ignore + import orjson _has_orjson: bool = True except ImportError: