From a210917b46b4bdee38b2c0a40c7a1bddac83bcc7 Mon Sep 17 00:00:00 2001 From: Robbe Sneyders Date: Mon, 23 Oct 2023 23:11:06 +0200 Subject: [PATCH] Drop Python 3.7 in favor of 3.11 and 3.12 (#1752) Python 3.7 is end of life. We should support the newer versions instead. I also changed tox to only run against the minimum dependency versions on the lowest Python version, since this should lead to the lowest versions over all Python versions, and hopefully helps speed up our pipelines :) --- .github/workflows/pipeline.yml | 2 +- connexion/apps/flask.py | 2 +- connexion/cli.py | 8 ++------ pyproject.toml | 5 ++--- tests/decorators/test_parameter.py | 8 +------- tests/test_api.py | 2 +- tox.ini | 10 ++++++---- 7 files changed, 14 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 191cb6467..8a2c3d54a 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} diff --git a/connexion/apps/flask.py b/connexion/apps/flask.py index 1bb1e229b..a584c344b 100644 --- a/connexion/apps/flask.py +++ b/connexion/apps/flask.py @@ -79,7 +79,7 @@ def _set_base_path(self, base_path: t.Optional[str] = None) -> None: self._set_blueprint() def _set_blueprint(self): - endpoint = flask_utils.flaskify_endpoint(self.base_path) + endpoint = flask_utils.flaskify_endpoint(self.base_path) or "/" self.blueprint = flask.Blueprint( endpoint, __name__, diff --git a/connexion/cli.py b/connexion/cli.py index 66be77c30..9af86c66f 100644 --- a/connexion/cli.py +++ b/connexion/cli.py @@ -3,6 +3,7 @@ starting point for developing your API with Connexion. """ +import importlib.metadata import logging import sys from os import path @@ -13,11 +14,6 @@ import connexion from connexion.mock import MockResolver -try: - import importlib_metadata -except ImportError: - import importlib.metadata as importlib_metadata # type: ignore - logger = logging.getLogger("connexion.cli") FLASK_APP = "flask" @@ -35,7 +31,7 @@ def print_version(ctx, param, value): if not value or ctx.resilient_parsing: return - click.echo(f"Connexion {importlib_metadata.version('connexion')}") + click.echo(f"Connexion {importlib.metadata.version('connexion')}") ctx.exit() diff --git a/pyproject.toml b/pyproject.toml index c1fcac83a..9f56ca8e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,11 +26,11 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Internet", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: HTTP Servers", @@ -44,11 +44,10 @@ classifiers = [ connexion = 'connexion.cli:main' [tool.poetry.dependencies] -python = '^3.7' +python = '^3.8' asgiref = ">= 3.4" clickclick = ">= 1.2" httpx = ">= 0.23" -importlib_metadata = { version = ">=6.0.0", python = "<3.8" } inflection = ">= 0.3.1" jsonschema = ">= 4.0.1" Jinja2 = ">= 3.0.0" diff --git a/tests/decorators/test_parameter.py b/tests/decorators/test_parameter.py index dd404d0df..4efcf50b5 100644 --- a/tests/decorators/test_parameter.py +++ b/tests/decorators/test_parameter.py @@ -1,11 +1,5 @@ import sys -from unittest.mock import MagicMock - -try: - from unittest.mock import AsyncMock -except ImportError: - # Python 3.7 - AsyncMock = None +from unittest.mock import AsyncMock, MagicMock import pytest from connexion.decorators.parameter import ( diff --git a/tests/test_api.py b/tests/test_api.py index 998f8ee71..4c9a40887 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -39,7 +39,7 @@ def test_api(): def test_api_base_path_slash(): api = FlaskApi(TEST_FOLDER / "fixtures/simple/basepath-slash.yaml") - assert api.blueprint.name == "" + assert api.blueprint.name == "/" assert api.blueprint.url_prefix == "" diff --git a/tox.ini b/tox.ini index d752579ed..6c036fa1e 100644 --- a/tox.ini +++ b/tox.ini @@ -9,15 +9,17 @@ extend-ignore=E203,RST303 [tox] isolated_build = True envlist = - {py37,py38,py39,py310}-{min,pypi} + py38-min + {py38,py39,py310,py311,py312}-pypi pre-commit [gh-actions] python = - 3.7: py37-min,py37-pypi 3.8: py38-min,py38-pypi - 3.9: py39-min,py39-pypi - 3.10: py310-min,py310-pypi,pre-commit + 3.9: py39-pypi + 3.10: py310-pypi + 3.11: py311-pypi,pre-commit + 3.12: py312-pypi [testenv] setenv=PYTHONPATH = {toxinidir}:{toxinidir}