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
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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 ]
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,21 @@ 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 = [
"tests.*",
]
# Allow test functions to be untyped
allow_untyped_defs = true
check_untyped_defs = true

[tool.ruff.lint]
extend-select = [
Expand Down
4 changes: 2 additions & 2 deletions scrapy_spider_metadata/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ 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


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:
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {})))