From 5e2806b5029b3e92de860834d93904e2e095455d Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 6 Dec 2022 14:08:53 -0800 Subject: [PATCH] [stable-2.14] ansible-test - Fix completion error in Python 3.11. (#79500) (cherry picked from commit 38fe342) Co-authored-by: Matt Clay --- .../ansible-test-fix-python-3.11-traceback.yml | 2 ++ .../ansible_test/_internal/cli/argparsing/parsers.py | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/ansible-test-fix-python-3.11-traceback.yml diff --git a/changelogs/fragments/ansible-test-fix-python-3.11-traceback.yml b/changelogs/fragments/ansible-test-fix-python-3.11-traceback.yml new file mode 100644 index 00000000000..717b917b79d --- /dev/null +++ b/changelogs/fragments/ansible-test-fix-python-3.11-traceback.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible-test - Added a work-around for a traceback under Python 3.11 when completing certain command line options. diff --git a/test/lib/ansible_test/_internal/cli/argparsing/parsers.py b/test/lib/ansible_test/_internal/cli/argparsing/parsers.py index c1f8ee00c4e..429b9c0cdf6 100644 --- a/test/lib/ansible_test/_internal/cli/argparsing/parsers.py +++ b/test/lib/ansible_test/_internal/cli/argparsing/parsers.py @@ -22,24 +22,26 @@ ASSIGNMENT_DELIMITER = '=' PATH_DELIMITER = '/' -@dataclasses.dataclass(frozen=True) +# This class was originally frozen. However, that causes issues when running under Python 3.11. +# See: https://github.com/python/cpython/issues/99856 +@dataclasses.dataclass class Completion(Exception): """Base class for argument completion results.""" -@dataclasses.dataclass(frozen=True) +@dataclasses.dataclass class CompletionUnavailable(Completion): """Argument completion unavailable.""" message: str = 'No completions available.' -@dataclasses.dataclass(frozen=True) +@dataclasses.dataclass class CompletionError(Completion): """Argument completion error.""" message: t.Optional[str] = None -@dataclasses.dataclass(frozen=True) +@dataclasses.dataclass class CompletionSuccess(Completion): """Successful argument completion result.""" list_mode: bool