From 6da8857fffa1ce699a7371fd0db8685281e80b19 Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Mon, 24 Mar 2025 23:53:27 +0500 Subject: [PATCH] Fix coverage upload, bump tool versions. --- .github/workflows/test.yml | 7 ++++--- .pre-commit-config.yaml | 2 +- .readthedocs.yml | 4 ++-- pyproject.toml | 10 ++++++++-- scrapy_spider_metadata/_utils.py | 4 ++-- tests/__init__.py | 2 +- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a61ec03..4dc2b11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,14 +31,15 @@ jobs: run: | tox -e ${{ matrix.toxenv || 'py' }} - name: coverage - if: ${{ success() }} - run: bash <(curl -s https://codecov.io/bash) + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} check: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - python-version: ['3.12'] # Keep in sync with .readthedocs.yml + python-version: ['3.13'] # Keep in sync with .readthedocs.yml tox-job: ["pre-commit", "mypy", "types", "docs", "twinecheck"] steps: - uses: actions/checkout@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7043ff8..3c92c4d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.6 + rev: v0.11.2 hooks: - id: ruff args: [ --fix ] diff --git a/.readthedocs.yml b/.readthedocs.yml index 333564d..5eff096 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -3,9 +3,9 @@ formats: all sphinx: configuration: docs/conf.py build: - os: ubuntu-22.04 + os: ubuntu-24.04 tools: - python: "3.12" # Keep in sync with .github/workflows/tests.yml + python: "3.13" # Keep in sync with .github/workflows/tests.yml python: install: - requirements: docs/requirements.txt diff --git a/pyproject.toml b/pyproject.toml index 9171afd..582288b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,8 +54,13 @@ filename = "scrapy_spider_metadata/__init__.py" search = '__version__ = "{current_version}"' replace = '__version__ = "{new_version}"' -[tool.mypy] -check_untyped_defs = true +[tool.coverage.run] +branch = true + +[tool.coverage.report] +exclude_also = [ + "if TYPE_CHECKING:", +] [[tool.mypy.overrides]] module = [ @@ -63,6 +68,7 @@ module = [ ] # Allow test functions to be untyped allow_untyped_defs = true +check_untyped_defs = true [tool.ruff.lint] extend-select = [ diff --git a/scrapy_spider_metadata/_utils.py b/scrapy_spider_metadata/_utils.py index 4cdd363..d264d56 100644 --- a/scrapy_spider_metadata/_utils.py +++ b/scrapy_spider_metadata/_utils.py @@ -20,7 +20,7 @@ def get_generic_param(cls: type, expected: type | tuple[type, ...]) -> type | No if origin and issubclass(origin, expected): result = get_args(base)[0] if not isinstance(result, TypeVar): - return cast(type, result) + return cast("type", result) queue.append(base) return None @@ -28,7 +28,7 @@ def get_generic_param(cls: type, expected: type | tuple[type, ...]) -> type | No def _normalize_param(key: str, value: dict[str, Any], defs: dict[str, Any], /) -> None: def get_def(ref: str) -> dict[str, Any]: def_id = ref.rsplit("/", maxsplit=1)[1] - return cast(dict[str, Any], defs[def_id]) + return cast("dict[str, Any]", defs[def_id]) extra = value.pop("json_schema_extra", None) if extra: diff --git a/tests/__init__.py b/tests/__init__.py index 6f942d1..66b958e 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -14,4 +14,4 @@ def get_spider( kwargs: dict[str, Any] | None = None, ) -> _SpiderT: crawler = get_crawler(spidercls, settings or {}) - return cast(_SpiderT, crawler._create_spider(spidercls.name, **(kwargs or {}))) + return cast("_SpiderT", crawler._create_spider(spidercls.name, **(kwargs or {})))