diff --git a/.github/actions/install/action.yml b/.github/actions/install/action.yml index 36326de8..c47b0907 100644 --- a/.github/actions/install/action.yml +++ b/.github/actions/install/action.yml @@ -10,15 +10,15 @@ runs: using: composite steps: - name: Checkout the source code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set the python version - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} - name: Set up pip package caching - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..be006de9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# Keep GitHub Actions up to date with GitHub's Dependabot... +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + groups: + github-actions: + patterns: + - "*" # Group all Actions updates into a single larger pull request + schedule: + interval: weekly diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 61251419..73d59679 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,21 +11,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the source code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - # This is the version of python used to package the code. The unit - # tests will have run against python 3.6, 3.7 etc ensuring - # compatibility with those runtimes. - # https://github.com/axnsan12/drf-yasg/pull/741#discussion_r713297594 - name: Set the python version - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.11 - name: Install dependencies uses: ./.github/actions/install with: - python-version: 3.8 + python-version: 3.11 - name: Install builders for publishing run: pip install -r requirements/publish.txt diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index 58fb45ec..4efe1949 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -7,15 +7,16 @@ jobs: name: Run linters and tests runs-on: "ubuntu-20.04" strategy: + fail-fast: false matrix: - python: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"] + python: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] steps: - name: Checkout the source code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set the python version - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} @@ -25,23 +26,23 @@ jobs: python-version: ${{ matrix.python }} - name: Run tests - + # Python 3.6 tests have been removed since swagger-spec-validator no longer supports it. # A successful workflow run for Python 3.6 is required by the GitHub branch protection rules. if: ${{ matrix.python != 3.6 }} - + env: PYTHON_VERSION: ${{ matrix.python }} run: tox -e $(tox -l | grep py${PYTHON_VERSION//.} | paste -sd "," -) - name: Report coverage - if: ${{ matrix.python == 3.9 }} + if: ${{ matrix.python != 3.6 }} run: | pip install coverage coverage report - name: Check for incompatibilities with publishing to PyPi - if: ${{ matrix.python == 3.8 }} + if: ${{ matrix.python == 3.11 }} run: | pip install -r requirements/publish.txt python setup.py sdist diff --git a/README.rst b/README.rst index 874beef2..5638808d 100644 --- a/README.rst +++ b/README.rst @@ -12,8 +12,8 @@ Generate **real** Swagger/OpenAPI 2.0 specifications from a Django Rest Framewor Compatible with - **Django Rest Framework**: 3.10, 3.11, 3.12, 3.13, 3.14 -- **Django**: 2.2, 3.0, 3.1, 3.2, 4.0, 4.1 -- **Python**: 3.6, 3.7, 3.8, 3.9, 3.10, 3.11 +- **Django**: 2.2, 3.0, 3.1, 3.2, 4.0, 4.1, 4.2 +- **Python**: 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12 Only the latest patch version of each ``major.minor`` series of Python, Django and Django REST Framework is supported. @@ -102,14 +102,14 @@ The preferred installation method is directly from pypi: .. code:: console - pip install -U drf-yasg + pip install --upgrade drf-yasg Additionally, if you want to use the built-in validation mechanisms (see `4. Validation`_), you need to install some extra requirements: .. code:: console - pip install -U drf-yasg[validation] + pip install --upgrade drf-yasg[validation] .. _readme-quickstart: @@ -132,7 +132,7 @@ In ``urls.py``: .. code:: python ... - from django.urls import path + from django.urls import re_path from rest_framework import permissions from drf_yasg.views import get_schema_view from drf_yasg import openapi @@ -297,7 +297,7 @@ You can use the specification outputted by this library together with $ docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate -i /local/tests/reference.yaml -l javascript -o /local/.codegen/js -See the github page linked above for more details. +See the GitHub page linked above for more details. .. _readme-testproj: @@ -313,8 +313,8 @@ For additional usage examples, you can take a look at the test project in the `` $ virtualenv venv $ source venv/bin/activate (venv) $ cd testproj - (venv) $ python -m pip install -U pip setuptools - (venv) $ pip install -U -r requirements.txt + (venv) $ python -m pip install --upgrade pip setuptools + (venv) $ pip install --upgrade -r requirements.txt (venv) $ python manage.py migrate (venv) $ python manage.py runserver (venv) $ firefox localhost:8000/swagger/ diff --git a/docs/conf.py b/docs/conf.py index 9e1259a0..83487358 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,7 +12,11 @@ from docutils import nodes, utils from docutils.parsers.rst import roles from docutils.parsers.rst.roles import set_classes -from pkg_resources import get_distribution + +try: + from importlib import metadata +except ImportError: # Python < 3.8 + from pkg_resources import get_distribution # -- General configuration ------------------------------------------------ @@ -47,7 +51,10 @@ # built documents. # The full version, including alpha/beta/rc tags. -release = get_distribution('drf_yasg').version +try: + release = metadata.version('drf_yasg') +except NameError: # Python < 3.8 + release = get_distribution('drf_yasg').version if 'noscm' in release: raise AssertionError('Invalid package version string: %s. \n' 'The documentation must be built with drf_yasg installed from a distribution package, ' @@ -82,7 +89,6 @@ # html_theme = 'default' html_theme = "sphinx_rtd_theme" -html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/pyproject.toml b/pyproject.toml index 4b48be08..81fdad32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["setuptools >= 40.6.3", "wheel", "setuptools-scm >= 3.0.3"] +requires = ["setuptools >= 68.0.0", "wheel", "setuptools-scm >= 3.0.3"] build-backend = "setuptools.build_meta" diff --git a/requirements/publish.txt b/requirements/publish.txt index ade35d85..4aeaa83e 100644 --- a/requirements/publish.txt +++ b/requirements/publish.txt @@ -1,3 +1,3 @@ setuptools-scm==7.0.5 -twine==4.0.1 +twine>=5.0.0 wheel>=0.37.0 diff --git a/src/drf_yasg/__init__.py b/src/drf_yasg/__init__.py index 21c6d57e..0f8df57a 100644 --- a/src/drf_yasg/__init__.py +++ b/src/drf_yasg/__init__.py @@ -1,11 +1,15 @@ # coding=utf-8 -from pkg_resources import DistributionNotFound, get_distribution __author__ = """Cristi V.""" __email__ = 'cristi@cvjd.me' try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: # pragma: no cover - # package is not installed - pass + from importlib.metadata import version + __version__ = version(__name__) +except ImportError: # Python < 3.8 + try: + from pkg_resources import DistributionNotFound, get_distribution + __version__ = get_distribution(__name__).version + except DistributionNotFound: # pragma: no cover + # package is not installed + pass diff --git a/src/drf_yasg/inspectors/field.py b/src/drf_yasg/inspectors/field.py index 9b767a8e..4d456fbf 100644 --- a/src/drf_yasg/inspectors/field.py +++ b/src/drf_yasg/inspectors/field.py @@ -8,7 +8,6 @@ from decimal import Decimal from inspect import signature as inspect_signature -import pkg_resources import typing from django.core import validators from django.db import models @@ -23,7 +22,12 @@ decimal_as_float, field_value_to_representation, filter_none, get_serializer_class, get_serializer_ref_name ) -drf_version = pkg_resources.get_distribution("djangorestframework").version +try: + from importlib import metadata + drf_version = metadata.version("djangorestframework") +except ImportError: # Python < 3.8 + import pkg_resources + drf_version = pkg_resources.get_distribution("djangorestframework").version logger = logging.getLogger(__name__) diff --git a/tox.ini b/tox.ini index 60b0dee8..4243327a 100644 --- a/tox.ini +++ b/tox.ini @@ -7,10 +7,14 @@ isolated_build_env = .package envlist = py{37,38,39}-django{22,30}-drf{310,311,312}, py{37,38,39}-django{31,32}-drf{311,312}, - py{39,310}-django{40,41}-drf{313,314} - py311-django{40,41,42}-drf314 + py{39,310}-django{40,41}-drf{313,314}, + # py311-django{40,41,42,50,51}-drf314, + py311-django{40,41,42}-drf314, + # py312-django{42,50,51}-drf314, + py312-django{42}-drf314, + # py313-django{51}-drf314, py38-{lint, docs}, - py310-djmaster + # py313-djmaster skip_missing_interpreters = true @@ -65,7 +69,6 @@ commands = deps = -r requirements/docs.txt commands = - twine check .tox/dist/* sphinx-build -WnEa -b html docs docs/_build/html [pytest] @@ -76,7 +79,7 @@ addopts = --ignore=node_modules [flake8] max-line-length = 120 exclude = **/migrations/* -ignore = F405,W504,I001,I005 +ignore = E721,F405,I001,I005,W504 [isort] skip = .eggs,.tox,docs,env,venv,node_modules,.git