From d5ab94a219a678ff17f58e6731a03b65d6b6053c Mon Sep 17 00:00:00 2001 From: ryneeverett Date: Sun, 31 Dec 2023 23:08:41 -0500 Subject: [PATCH] python-3.11 compatibility Resolve #1021. --- .github/workflows/bugwarrior.yml | 4 ++-- bugwarrior/services/bts.py | 21 ++++++++++++++++++++- setup.py | 2 +- tests/test_bts.py | 8 +++++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bugwarrior.yml b/.github/workflows/bugwarrior.yml index f69ae2f2..001d7932 100644 --- a/.github/workflows/bugwarrior.yml +++ b/.github/workflows/bugwarrior.yml @@ -10,7 +10,7 @@ jobs: timeout-minutes: 5 strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9, "3.10"] + python-version: [3.6, 3.7, 3.8, 3.9, "3.10", 3.11] jira-version: [1.0.10, 2.0.0] steps: - name: Checkout code @@ -50,7 +50,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9, "3.10"] + python-version: [3.6, 3.7, 3.8, 3.9, "3.10", 3.11] jira-version: [1.0.10, 2.0.0] architecture: [aarch64, ppc64le] diff --git a/bugwarrior/services/bts.py b/bugwarrior/services/bts.py index e46b6c4e..61febdba 100644 --- a/bugwarrior/services/bts.py +++ b/bugwarrior/services/bts.py @@ -1,4 +1,5 @@ -import debianbts +import sys + import pydantic import requests import typing_extensions @@ -9,6 +10,14 @@ import logging log = logging.getLogger(__name__) +try: + import debianbts +except AttributeError as e: + # Suppress exception if we're just building docs in python-3.11+. + if 'sphinx' not in ''.join(sys.argv): + log.warning('debianbts does not support python-3.11+') + raise e + UDD_BUGS_SEARCH = "https://udd.debian.org/bugs/" @@ -37,6 +46,16 @@ def udd_needs_email(cls, values): raise ValueError("no 'email' but UDD search was requested") return values + @pydantic.root_validator + def python_version_limited(cls, values): + log.warning( + 'The Debian BTS service has a dependency that has not yet been ' + 'ported to python-3.11+. If this has not been resolved by October ' + '2026, when python-3.10 hits EOL, this service is liable to be ' + 'removed. See ' + '.') + return values + class BTSIssue(Issue): SUBJECT = 'btssubject' diff --git a/setup.py b/setup.py index 725228d3..c761a231 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ extras = { "activecollab": ["pypandoc", "pyac>=0.1.5"], - "bts": ["PySimpleSOAP", "python-debianbts>=2.6.1"], + "bts": ["python-debianbts>=2.6.1"], "bugzilla": ["python-bugzilla>=2.0.0"], "gmail": ["google-api-python-client", "google-auth-oauthlib"], "ini2toml": ["ini2toml[full]"], diff --git a/tests/test_bts.py b/tests/test_bts.py index c1ccadf4..a372fd76 100644 --- a/tests/test_bts.py +++ b/tests/test_bts.py @@ -1,4 +1,10 @@ -from unittest import mock +import sys +from unittest import mock, SkipTest + +if sys.version_info >= (3, 11): + raise SkipTest( + "Python-3.11+ not supported. " + "See .") from bugwarrior.services import bts