diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index c6c3c25e..e405d45f 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -1,22 +1,13 @@ name: build on: push: - branches: ["dev"] + branches: ["dev", "*.x-line"] tags: ["*"] pull_request: # Run builds nightly to catch incompatibilities with new marshmallow releases schedule: - cron: "0 0 * * *" jobs: - lint: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - run: python -m pip install --upgrade pip wheel - - run: pip install tox - - run: tox -elint tests: name: ${{ matrix.name }} runs-on: ${{ matrix.os }} @@ -31,16 +22,16 @@ jobs: tox: py38-marshmallow3, } - { - name: "3.11-ma3", - python: "3.11", + name: "3.12-ma3", + python: "3.12", os: ubuntu-latest, - tox: py311-marshmallow3, + tox: py312-marshmallow3, } - { - name: "3.11-madev", - python: "3.11", + name: "3.12-madev", + python: "3.12", os: ubuntu-latest, - tox: py311-marshmallowdev, + tox: py312-marshmallowdev, } steps: - uses: actions/checkout@v2 @@ -50,8 +41,22 @@ jobs: - run: python -m pip install --upgrade pip wheel - run: pip install tox - run: tox -e${{ matrix.tox }} + # this duplicates pre-commit.ci, so only run it on tags + # it guarantees that linting is passing prior to a release + lint-pre-release: + name: lint + if: startsWith(github.ref, 'refs/tags') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.1.0 + - uses: actions/setup-python@v4.3.0 + with: + python-version: "3.11" + - run: python -m pip install --upgrade pip + - run: python -m pip install tox + - run: python -m tox -elint release: - needs: [lint, tests] + needs: [tests, lint-pre-release] name: PyPI release if: startsWith(github.ref, 'refs/tags') runs-on: ubuntu-latest diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0e7d3306..05dc58a2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,7 +6,9 @@ Changelog Other changes: +- Support Python 3.12. - Drop support for Python 3.7, which is EOL. +- Remove `[validation]` from extras, as it is no longer used. 6.3.1 (2023-12-21) diff --git a/pyproject.toml b/pyproject.toml index 16955db2..4c6215c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [tool.black] line-length = 88 -target-version = ['py38', 'py39', 'py310', 'py311'] +target-version = ['py38', 'py39', 'py310', 'py311', 'py312'] diff --git a/setup.py b/setup.py index f244d6c0..916b8b8a 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,6 @@ EXTRAS_REQUIRE = { "marshmallow": ["marshmallow>=3.18.0"], "yaml": ["PyYAML>=3.10"], - "validation": ["prance[osv]>=0.11"], "lint": [ "flake8==7.0.0", "flake8-bugbear==22.12.6", @@ -22,11 +21,11 @@ "sphinx-rtd-theme==2.0.0", ], } -EXTRAS_REQUIRE["tests"] = ( - EXTRAS_REQUIRE["yaml"] - + EXTRAS_REQUIRE["validation"] - + ["marshmallow>=3.13.0", "pytest"] -) +EXTRAS_REQUIRE["tests"] = EXTRAS_REQUIRE["yaml"] + [ + "marshmallow>=3.13.0", + "openapi-spec-validator==0.7.1", + "pytest", +] EXTRAS_REQUIRE["dev"] = EXTRAS_REQUIRE["tests"] + EXTRAS_REQUIRE["lint"] + ["tox"] @@ -78,6 +77,7 @@ def read(fname): "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3 :: Only", ], test_suite="tests", diff --git a/tests/utils.py b/tests/utils.py index 9416e268..ef8efd5a 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,5 +1,6 @@ """Utilities to get elements of generated spec""" -import json +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError from apispec.core import APISpec from apispec import exceptions @@ -52,28 +53,12 @@ def validate_spec(spec: APISpec) -> bool: """Validate the output of an :class:`APISpec` object against the OpenAPI specification. - Note: Requires installing apispec with the ``[validation]`` extras. - :: - - pip install 'apispec[validation]' - :raise: apispec.exceptions.OpenAPIError if validation fails. """ try: - import prance - except ImportError as error: # re-raise with a more verbose message - exc_class = type(error) - raise exc_class( - "validate_spec requires prance to be installed. " - "You can install all validation requirements using:\n" - " pip install 'apispec[validation]'" - ) from error - parser_kwargs = {} - if spec.openapi_version.major == 3: - parser_kwargs["backend"] = "openapi-spec-validator" - try: - prance.BaseParser(spec_string=json.dumps(spec.to_dict()), **parser_kwargs) - except prance.ValidationError as err: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: raise exceptions.OpenAPIError(*err.args) from err else: return True diff --git a/tox.ini b/tox.ini index 38470491..eb1baab8 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] envlist= lint - py{38,39,310,311}-marshmallow3 - py311-marshmallowdev + py{38,39,310,311,312}-marshmallow3 + py312-marshmallowdev docs [testenv]