diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 84992d3..fe22f55 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d52878..2a577c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7521519..26902e1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: @@ -18,4 +18,4 @@ repos: - flake8-docstrings - flake8-string-format repo: https://github.com/pycqa/flake8 - rev: 6.1.0 + rev: 7.1.1 diff --git a/.readthedocs.yml b/.readthedocs.yml index d98a87a..333564d 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 430d23d..370a020 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", ] diff --git a/tests/test_params.py b/tests/test_params.py index fe1fd5a..6a58fcf 100644 --- a/tests/test_params.py +++ b/tests/test_params.py @@ -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 @@ -12,6 +12,9 @@ from . import get_spider +if TYPE_CHECKING: + from pydantic.config import JsonDict + class Params(BaseModel): foo: int @@ -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", @@ -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"], @@ -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", } ), diff --git a/tox.ini b/tox.ini index 6700f95..3834640 100644 --- a/tox.ini +++ b/tox.ini @@ -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} @@ -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/*