Skip to content

Commit

Permalink
Merge pull request #17 from scrapy-plugins/modernize
Browse files Browse the repository at this point in the history
Add Python 3.12 to CI, update tool versions
  • Loading branch information
wRAR authored Sep 26, 2024
2 parents 950838a + 84d1391 commit 507d17e
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 50 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: '3.12'
- name: Install dependencies
run: |
pip install --upgrade build twine
python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.6.4
uses: pypa/gh-action-pypi-publish@v1.10.2
with:
password: ${{ secrets.PYPI_TOKEN }}
11 changes: 6 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ jobs:
- python-version: "3.9"
- python-version: "3.10"
- python-version: "3.11"
- python-version: "3.12"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -37,12 +38,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.11'] # Keep in sync with .readthedocs.yml
python-version: ['3.12'] # Keep in sync with .readthedocs.yml
tox-job: ["pre-commit", "mypy", "types", "docs", "twinecheck"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ repos:
- hooks:
- id: black
repo: https://github.com/ambv/black
rev: 23.9.1
rev: 24.8.0
- hooks:
- id: isort
repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
- hooks:
- id: flake8
additional_dependencies:
Expand All @@ -18,4 +18,4 @@ repos:
- flake8-docstrings
- flake8-string-format
repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.1.1
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sphinx:
build:
os: ubuntu-22.04
tools:
python: "3.11" # Keep in sync with .github/workflows/tests.yml
python: "3.12" # Keep in sync with .github/workflows/tests.yml
python:
install:
- requirements: docs/requirements.txt
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
Expand Down
78 changes: 45 additions & 33 deletions tests/test_params.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum, IntEnum
from typing import Any, Dict, Optional, Type
from typing import TYPE_CHECKING, Any, Dict, Optional, Type, cast

import pytest
from packaging import version
Expand All @@ -12,6 +12,9 @@

from . import get_spider

if TYPE_CHECKING:
from pydantic.config import JsonDict


class Params(BaseModel):
foo: int
Expand Down Expand Up @@ -316,25 +319,29 @@ class ParamSpider(Args[Params], Spider):
"type": "integer",
"default": 1,
},
"int_optional": {
"title": "Int Optional",
"anyOf": [{"type": "integer"}, {"type": "null"}],
"default": None,
}
if not USING_PYDANTIC_1
else {
"title": "Int Optional",
"type": "integer",
},
"int_optional_without_default": {
"title": "Int Optional Without Default",
"anyOf": [{"type": "integer"}, {"type": "null"}],
}
if not USING_PYDANTIC_1
else {
"title": "Int Optional Without Default",
"type": "integer",
},
"int_optional": (
{
"title": "Int Optional",
"anyOf": [{"type": "integer"}, {"type": "null"}],
"default": None,
}
if not USING_PYDANTIC_1
else {
"title": "Int Optional",
"type": "integer",
}
),
"int_optional_without_default": (
{
"title": "Int Optional Without Default",
"anyOf": [{"type": "integer"}, {"type": "null"}],
}
if not USING_PYDANTIC_1
else {
"title": "Int Optional Without Default",
"type": "integer",
}
),
"number_without_default": {
"title": "Number Without Default",
"type": "number",
Expand Down Expand Up @@ -385,18 +392,20 @@ class ParamSpider(Args[Params], Spider):
},
},
},
"dessert_optional": {
"title": "Dessert Optional",
"enum": ["cake", "cookie"],
"anyOf": [{"type": "string"}, {"type": "null"}],
"default": None,
}
if not USING_PYDANTIC_1
else {
"title": "Dessert Optional",
"enum": ["cake", "cookie"],
"type": "string",
},
"dessert_optional": (
{
"title": "Dessert Optional",
"enum": ["cake", "cookie"],
"anyOf": [{"type": "string"}, {"type": "null"}],
"default": None,
}
if not USING_PYDANTIC_1
else {
"title": "Dessert Optional",
"enum": ["cake", "cookie"],
"type": "string",
}
),
"dessert_required": {
"title": "Dessert Required",
"enum": ["cake", "cookie"],
Expand Down Expand Up @@ -607,7 +616,10 @@ class Params(ParentParams):
**ParentParams.model_config,
**ConfigDict(
json_schema_extra={
**ParentParams.model_config.get("json_schema_extra", {}),
**cast(
"JsonDict",
ParentParams.model_config.get("json_schema_extra", {}),
),
"c": "d",
}
),
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ commands = pre-commit run --all-files --show-diff-on-failure

[testenv:mypy]
deps =
mypy==1.5.1
pytest==7.4.2
mypy==1.11.2
pytest==8.3.3
commands = mypy {posargs:scrapy_spider_metadata tests}

[testenv:types]
deps =
{[testenv]deps}
{[testenv:mypy]deps}
pytest-mypy-testing==0.1.1
pytest-mypy-testing==0.1.3
commands =
pytest {posargs:tests_typing}

Expand All @@ -58,7 +58,7 @@ commands =
basepython = python3
deps =
twine==5.1.1
build==1.2.1
build==1.2.2
commands =
python -m build --sdist
twine check dist/*

0 comments on commit 507d17e

Please sign in to comment.