From 8c90cfe6a74a6ef74df01c45b996a430e9d1751e Mon Sep 17 00:00:00 2001 From: Joao Detomini Date: Tue, 11 Aug 2026 10:57:56 -0300 Subject: [PATCH] Drop support for Python versions older than 3.12 pg-backup-api now requires Python 3.12 or higher. This aligns with the broader project's move to edb-python312 and enables a minor release cycle. CI matrices and tox are updated to cover Python 3.12, 3.13, and 3.14. The change is documented in news.yml under the upcoming 2.3.0 release. References: BAR-1568 Signed-off-by: Joao Detomini --- .github/workflows/tests.yml | 14 +++------- pg_backup_api/news.yml | 8 ++++++ .../pg_backup_api/tests/test_main.py | 23 +++++++++++----- .../tests/test_utility_controller.py | 27 ------------------- pg_backup_api/setup.py | 2 +- pg_backup_api/tox.ini | 8 +++--- 6 files changed, 34 insertions(+), 48 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a4ead81..50e64e4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -74,12 +74,9 @@ jobs: matrix: python-version: - - '3.7' - - '3.8' - - '3.9' - - '3.10' - - '3.11' - '3.12' + - '3.13' + - '3.14' steps: - name: Checkout the source code @@ -109,12 +106,9 @@ jobs: matrix: python-version: - - '3.7' - - '3.8' - - '3.9' - - '3.10' - - '3.11' - '3.12' + - '3.13' + - '3.14' steps: - name: Checkout the source code diff --git a/pg_backup_api/news.yml b/pg_backup_api/news.yml index e6e9812..a997f37 100644 --- a/pg_backup_api/news.yml +++ b/pg_backup_api/news.yml @@ -3,6 +3,14 @@ # pg-backup-api News - History of user-visible changes pg-backup-api release notes: + - version: "2.3.0" + date: "20260826" + changes: + Notable changes: + - | + Drop support for Python versions older than 3.12. The earliest Python + version supported is now 3.12. + - version: "2.2.0" date: "20250912" changes: diff --git a/pg_backup_api/pg_backup_api/tests/test_main.py b/pg_backup_api/pg_backup_api/tests/test_main.py index 1b1bba9..b1bdc22 100644 --- a/pg_backup_api/pg_backup_api/tests/test_main.py +++ b/pg_backup_api/pg_backup_api/tests/test_main.py @@ -17,7 +17,7 @@ # along with Postgres Backup API. If not, see . """Unit tests for the CLI.""" -import sys +import re from textwrap import dedent from unittest.mock import MagicMock, patch @@ -26,6 +26,18 @@ from pg_backup_api.__main__ import main +def _normalize_usage(text): + """Collapse argparse usage line continuations into a single line. + + argparse changed its line-wrapping algorithm in Python 3.13, causing the + usage line to break at different points across versions. Normalizing both + the actual and expected output makes the comparison version-agnostic. + """ + head, sep, rest = text.partition("\n\n") + head = re.sub(r"\n\s+(?=\S)", " ", head) + return head + (sep + rest if sep else "") + + _HELP_OUTPUT = { "pg-backup-api --help": dedent( """\ @@ -142,13 +154,10 @@ def test_main_helper(mock_term_size, command, capsys): assert str(exc.value) == "0" - expected = _HELP_OUTPUT[command] - version = sys.version_info - - if version.major >= 3 and version.minor >= 10: - expected = expected.replace("optional arguments:", "options:") + expected = _HELP_OUTPUT[command].replace("optional arguments:", "options:") - assert capsys.readouterr().out == expected + actual = _normalize_usage(capsys.readouterr().out) + assert actual == _normalize_usage(expected) @pytest.mark.parametrize("command", _COMMAND_FUNC.keys()) diff --git a/pg_backup_api/pg_backup_api/tests/test_utility_controller.py b/pg_backup_api/pg_backup_api/tests/test_utility_controller.py index 0276abb..91f6a04 100644 --- a/pg_backup_api/pg_backup_api/tests/test_utility_controller.py +++ b/pg_backup_api/pg_backup_api/tests/test_utility_controller.py @@ -17,12 +17,9 @@ # along with Postgres Backup API. If not, see . """Unit tests for the REST API endpoints.""" -from distutils.version import StrictVersion import json -import sys from unittest.mock import Mock, MagicMock, patch -import flask import pytest from pg_backup_api.server_operation import ( @@ -346,18 +343,6 @@ def test_server_operation_post_not_json(self, client): expected_status_code = 415 expected_data = b"Unsupported Media Type" - version = sys.version_info - - # This is an issue which was detected while running tests through - # GitHub Actions when using Python 3.7 and Flask 2.2.5. We might want - # to remove this once we remove support for Python 3.7 - if ( - version.major <= 3 - and version.minor <= 7 - and StrictVersion(flask.__version__) <= StrictVersion("2.2.5") - ): - expected_status_code = 400 - expected_data = b"Bad Request" assert response.status_code == expected_status_code assert expected_data in response.data @@ -833,18 +818,6 @@ def test_instance_operation_post_not_json(self, client): expected_status_code = 415 expected_data = b"Unsupported Media Type" - version = sys.version_info - - # This is an issue which was detected while running tests through - # GitHub Actions when using Python 3.7 and Flask 2.2.5. We might want - # to remove this once we remove support for Python 3.7 - if ( - version.major <= 3 - and version.minor <= 7 - and StrictVersion(flask.__version__) <= StrictVersion("2.2.5") - ): - expected_status_code = 400 - expected_data = b"Bad Request" assert response.status_code == expected_status_code assert expected_data in response.data diff --git a/pg_backup_api/setup.py b/pg_backup_api/setup.py index 9627e3a..9a5ff0a 100644 --- a/pg_backup_api/setup.py +++ b/pg_backup_api/setup.py @@ -44,7 +44,7 @@ author_email="barman@enterprisedb.com", url="http://www.pgbarman.org/", keywords=["Postgres Backup REST API"], - python_requires=">=3.6", + python_requires=">=3.12", install_requires=REQUIRES, packages=find_packages(exclude=["tests"]), include_package_data=True, diff --git a/pg_backup_api/tox.ini b/pg_backup_api/tox.ini index dfced40..1f7c1f8 100644 --- a/pg_backup_api/tox.ini +++ b/pg_backup_api/tox.ini @@ -1,5 +1,5 @@ [common] -python_matrix = {37,38,39,310,311} +python_matrix = {312,313,314} platforms = lin: linux mac: darwin @@ -33,7 +33,7 @@ commands = flake8 {posargs:pg_backup_api setup.py} deps = flake8 -[testenv:py{37,38,39,310,311}-test-{lin,win,mac}] +[testenv:py{312,313,314}-test-{lin,win,mac}] description = Run unit tests with pytest labels = test @@ -72,7 +72,7 @@ deps = -r requirements.txt pipdeptree -[testenv:py{37,38,39,310,311}-type-{lin,mac,win}] +[testenv:py{312,313,314}-type-{lin,mac,win}] description = Run static type checking with pyright labels = type @@ -85,6 +85,8 @@ platform = [flake8] max-line-length = 79 +per-file-ignores = + pg_backup_api/tests/*.py:E501 [coverage:run] omit =