Skip to content

Commit

Permalink
Review: Test on the current versions of CPython
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed Oct 15, 2024
1 parent 2ee3935 commit 51fd3f1
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
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
Expand All @@ -26,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
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
11 changes: 9 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------

Expand Down Expand Up @@ -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, '
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 9 additions & 5 deletions src/drf_yasg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# coding=utf-8
from pkg_resources import DistributionNotFound, get_distribution

__author__ = """Cristi V."""
__email__ = '[email protected]'

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
8 changes: 6 additions & 2 deletions src/drf_yasg/inspectors/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__)

Expand Down
10 changes: 7 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 51fd3f1

Please sign in to comment.