Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,28 @@ jobs:

- uses: astral-sh/ruff-action@v3
with:
version: ${{ steps.ruff-version.outputs.version }}
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'
4 changes: 2 additions & 2 deletions fortnite_api/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions fortnite_api/proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions fortnite_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -36,7 +36,7 @@
from collections.abc import Hashable

try:
import orjson # type: ignore
import orjson

_has_orjson: bool = True
except ImportError:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions tests/client/test_client_hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Loading